@@ -25,6 +25,7 @@ var util = require('util'),
2525 pbxFile = require ( './pbxFile' ) . pbxFile ,
2626 isSourceOrHeaderFileType = require ( './pbxFile' ) . isSourceOrHeaderFileType ,
2727 isHeaderFileType = require ( './pbxFile' ) . isHeaderFileType ,
28+ isResource = require ( './pbxFile' ) . isResource ,
2829 fs = require ( 'fs' ) ,
2930 parser = require ( './parser/pbxproj' ) ,
3031 plist = require ( 'simple-plist' ) ,
@@ -557,14 +558,19 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
557558 var srcRootPath = $path . dirname ( $path . dirname ( this . filepath ) ) ;
558559 var relativePath = $path . relative ( srcRootPath , filePath ) ;
559560 var file = new pbxFile ( opt . filesRelativeToProject ? relativePath : filePath ) ;
561+
562+ if ( opt . target ) {
563+ file . target = opt . target ;
564+ }
565+
560566 if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) ) {
561567 file . uuid = this . generateUuid ( ) ;
562568 file . fileRef = file . uuid ;
563569 this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
564570 this . addToPbxBuildFileSection ( file ) ;
565571 pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
566572 var files = fs . readdirSync ( filePath ) . map ( p => $path . join ( filePath , p ) ) ;
567- this . addPbxGroup ( files , $path . basename ( filePath ) , filePath , null , { uuid : file . uuid , filesRelativeToProject : opt . filesRelativeToProject } ) ;
573+ this . addPbxGroup ( files , $path . basename ( filePath ) , filePath , null , { uuid : file . uuid , filesRelativeToProject : opt . filesRelativeToProject , target : opt . target } ) ;
568574 } else if ( isSourceOrHeaderFileType ( file . lastKnownFileType ) ) {
569575 file . uuid = this . generateUuid ( ) ;
570576 file . fileRef = this . generateUuid ( ) ;
@@ -574,6 +580,12 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
574580 this . addToPbxSourcesBuildPhase ( file ) ;
575581 }
576582 pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
583+ } else if ( isResource ( file . group ) ) {
584+ file . uuid = this . generateUuid ( ) ;
585+ file . fileRef = this . generateUuid ( ) ;
586+ this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
587+ this . addToPbxResourcesBuildPhase ( file )
588+ pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
577589 } else {
578590 file . uuid = this . generateUuid ( ) ;
579591 file . fileRef = this . generateUuid ( ) ;
@@ -922,6 +934,14 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
922934 pbxTargetDependencySection = this . hash . project . objects [ pbxTargetDependency ] ,
923935 pbxContainerItemProxySection = this . hash . project . objects [ pbxContainerItemProxy ] ;
924936
937+ if ( ! pbxTargetDependencySection ) {
938+ pbxTargetDependencySection = this . hash . project . objects [ pbxTargetDependency ] = { } ;
939+ }
940+
941+ if ( ! pbxContainerItemProxySection ) {
942+ pbxContainerItemProxySection = this . hash . project . objects [ pbxContainerItemProxy ] = { } ;
943+ }
944+
925945 for ( var index = 0 ; index < dependencyTargets . length ; index ++ ) {
926946 var dependencyTargetUuid = dependencyTargets [ index ] ,
927947 dependencyTargetCommentKey = f ( "%s_comment" , dependencyTargetUuid ) ,
@@ -934,7 +954,7 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
934954 containerPortal : this . hash . project [ 'rootObject' ] ,
935955 containerPortal_comment : this . hash . project [ 'rootObject_comment' ] ,
936956 proxyType : 1 ,
937- remoteGlobalIDString : dependencyTargetUuid ,
957+ remoteGlobalIDString : dependencyTargetUuid ,
938958 remoteInfo : nativeTargets [ dependencyTargetUuid ] . name
939959 } ,
940960 targetDependency = {
@@ -1158,8 +1178,8 @@ pbxProject.prototype.buildPhase = function(group, target) {
11581178 var buildPhase = buildPhases [ i ] ;
11591179 if ( buildPhase . comment == group )
11601180 return buildPhase . value + "_comment" ;
1161- }
11621181 }
1182+ }
11631183
11641184pbxProject . prototype . buildPhaseObject = function ( name , group , target ) {
11651185 var section = this . hash . project . objects [ name ] ,
0 commit comments