@@ -25,6 +25,7 @@ var util = require('util'),
25
25
pbxFile = require ( './pbxFile' ) . pbxFile ,
26
26
isSourceOrHeaderFileType = require ( './pbxFile' ) . isSourceOrHeaderFileType ,
27
27
isHeaderFileType = require ( './pbxFile' ) . isHeaderFileType ,
28
+ isResource = require ( './pbxFile' ) . isResource ,
28
29
fs = require ( 'fs' ) ,
29
30
parser = require ( './parser/pbxproj' ) ,
30
31
plist = require ( 'simple-plist' ) ,
@@ -557,14 +558,19 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
557
558
var srcRootPath = $path . dirname ( $path . dirname ( this . filepath ) ) ;
558
559
var relativePath = $path . relative ( srcRootPath , filePath ) ;
559
560
var file = new pbxFile ( opt . filesRelativeToProject ? relativePath : filePath ) ;
561
+
562
+ if ( opt . target ) {
563
+ file . target = opt . target ;
564
+ }
565
+
560
566
if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) ) {
561
567
file . uuid = this . generateUuid ( ) ;
562
568
file . fileRef = file . uuid ;
563
569
this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
564
570
this . addToPbxBuildFileSection ( file ) ;
565
571
pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
566
572
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 } ) ;
568
574
} else if ( isSourceOrHeaderFileType ( file . lastKnownFileType ) ) {
569
575
file . uuid = this . generateUuid ( ) ;
570
576
file . fileRef = this . generateUuid ( ) ;
@@ -574,6 +580,12 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
574
580
this . addToPbxSourcesBuildPhase ( file ) ;
575
581
}
576
582
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 ) ) ;
577
589
} else {
578
590
file . uuid = this . generateUuid ( ) ;
579
591
file . fileRef = this . generateUuid ( ) ;
@@ -922,6 +934,14 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
922
934
pbxTargetDependencySection = this . hash . project . objects [ pbxTargetDependency ] ,
923
935
pbxContainerItemProxySection = this . hash . project . objects [ pbxContainerItemProxy ] ;
924
936
937
+ if ( ! pbxTargetDependencySection ) {
938
+ pbxTargetDependencySection = this . hash . project . objects [ pbxTargetDependency ] = { } ;
939
+ }
940
+
941
+ if ( ! pbxContainerItemProxySection ) {
942
+ pbxContainerItemProxySection = this . hash . project . objects [ pbxContainerItemProxy ] = { } ;
943
+ }
944
+
925
945
for ( var index = 0 ; index < dependencyTargets . length ; index ++ ) {
926
946
var dependencyTargetUuid = dependencyTargets [ index ] ,
927
947
dependencyTargetCommentKey = f ( "%s_comment" , dependencyTargetUuid ) ,
@@ -934,7 +954,7 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
934
954
containerPortal : this . hash . project [ 'rootObject' ] ,
935
955
containerPortal_comment : this . hash . project [ 'rootObject_comment' ] ,
936
956
proxyType : 1 ,
937
- remoteGlobalIDString : dependencyTargetUuid ,
957
+ remoteGlobalIDString : dependencyTargetUuid ,
938
958
remoteInfo : nativeTargets [ dependencyTargetUuid ] . name
939
959
} ,
940
960
targetDependency = {
@@ -1158,8 +1178,8 @@ pbxProject.prototype.buildPhase = function(group, target) {
1158
1178
var buildPhase = buildPhases [ i ] ;
1159
1179
if ( buildPhase . comment == group )
1160
1180
return buildPhase . value + "_comment" ;
1161
- }
1162
1181
}
1182
+ }
1163
1183
1164
1184
pbxProject . prototype . buildPhaseObject = function ( name , group , target ) {
1165
1185
var section = this . hash . project . objects [ name ] ,
0 commit comments