@@ -26,7 +26,9 @@ var util = require('util'),
26
26
isSourceFileType = require ( './pbxFile' ) . isSourceFileType ,
27
27
isHeaderFileType = require ( './pbxFile' ) . isHeaderFileType ,
28
28
isResource = require ( './pbxFile' ) . isResource ,
29
- isEntitlement = require ( './pbxFile' ) . isEntitlement
29
+ isEntitlement = require ( './pbxFile' ) . isEntitlement ,
30
+ isAssetFileType = require ( './pbxFile' ) . isAssetFileType ,
31
+ isPlist = require ( './pbxFile' ) . isPlist ,
30
32
fs = require ( 'fs' ) ,
31
33
parser = require ( './parser/pbxproj' ) ,
32
34
plist = require ( 'simple-plist' ) ,
@@ -566,18 +568,11 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
566
568
if ( opt . target ) {
567
569
file . target = opt . target ;
568
570
}
569
- if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) ) {
571
+ if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) && ! isAssetFileType ( file . lastKnownFileType ) ) {
570
572
file . fileRef = file . uuid ;
571
573
var files = fs . readdirSync ( filePath ) . map ( p => $path . join ( filePath , p ) ) ;
572
574
if ( $path . extname ( filePath ) === ".lproj" ) {
573
- for ( var i = 0 ; i < files . length ; i ++ ) {
574
- var variantGroup = this . addLocalizationVariantGroup ( $path . basename ( files [ i ] ) , { target : opt . target , skipAddToResourcesGroup : true } ) ;
575
- var refFile = new pbxFile ( $path . relative ( srcRootPath , files [ i ] ) , { basename : $path . parse ( file . basename ) . name } ) ;
576
- refFile . fileRef = this . generateUuid ( ) ;
577
- this . addToPbxFileReferenceSection ( refFile ) ;
578
- this . addToPbxVariantGroup ( refFile , variantGroup . fileRef ) ;
579
- pbxGroup . children . push ( pbxGroupChild ( variantGroup ) ) ;
580
- }
575
+ addLocalizationGroup . call ( this , pbxGroup , file , files , srcRootPath , opt ) ;
581
576
} else {
582
577
this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
583
578
this . addToPbxBuildFileSection ( file ) ;
@@ -587,18 +582,22 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
587
582
} else {
588
583
this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
589
584
pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
590
- if ( isHeaderFileType ( file . lastKnownFileType ) ) {
585
+ if ( isHeaderFileType ( file . lastKnownFileType ) || isPlist ( file . lastKnownFileType ) ) {
591
586
continue ;
592
- } else if ( isSourceFileType ( file . lastKnownFileType ) ) {
593
- this . addToPbxBuildFileSection ( file ) ; // PBXBuildFile
594
- this . addToPbxSourcesBuildPhase ( file ) ;
595
- } else if ( isEntitlement ( file . lastKnownFileType ) ) {
587
+ }
588
+
589
+ if ( isEntitlement ( file . lastKnownFileType ) ) {
596
590
this . addToBuildSettings ( 'CODE_SIGN_ENTITLEMENTS' , file . path , opt . target ) ;
591
+ continue ;
592
+ }
593
+
594
+ if ( isSourceFileType ( file . lastKnownFileType ) ) { // PBXBuildFile
595
+ this . addToPbxSourcesBuildPhase ( file ) ;
597
596
} else if ( isResource ( file . group ) ) {
598
597
this . addToPbxResourcesBuildPhase ( file )
599
- } else {
600
- this . addToPbxBuildFileSection ( file ) ;
601
598
}
599
+
600
+ this . addToPbxBuildFileSection ( file ) ;
602
601
}
603
602
}
604
603
@@ -619,6 +618,21 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
619
618
return { uuid : pbxGroupUuid , pbxGroup : pbxGroup } ;
620
619
}
621
620
621
+ function addLocalizationGroup ( pbxGroup , variantFile , files , srcRootPath , opt ) {
622
+ for ( var i = 0 ; i < files . length ; i ++ ) {
623
+ var variantGroupName = $path . parse ( $path . basename ( files [ i ] ) ) . name + ".storyboard" ;
624
+ var variantGroup = this . findPBXVariantGroupKey ( { name : variantGroupName } ) ;
625
+ if ( ! variantGroup ) {
626
+ variantGroup = this . addLocalizationVariantGroup ( variantGroupName , { target : opt . target , skipAddToResourcesGroup : true } ) ;
627
+ pbxGroup . children . push ( pbxGroupChild ( variantGroup ) ) ;
628
+ }
629
+ var refFile = new pbxFile ( $path . relative ( srcRootPath , files [ i ] ) , { basename : $path . parse ( variantFile . basename ) . name } ) ;
630
+ refFile . fileRef = this . generateUuid ( ) ;
631
+ this . addToPbxFileReferenceSection ( refFile ) ;
632
+ this . addToPbxVariantGroup ( refFile , variantGroup . fileRef ) ;
633
+ }
634
+ }
635
+
622
636
pbxProject . prototype . removePbxGroup = function ( groupName , path ) {
623
637
var group = this . pbxGroupByName ( groupName ) ;
624
638
if ( ! group ) {
@@ -1375,15 +1389,17 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function(file) {
1375
1389
1376
1390
}
1377
1391
}
1378
- pbxProject . prototype . addToHeaderSearchPaths = function ( file ) {
1392
+ pbxProject . prototype . addToHeaderSearchPaths = function ( file , productName ) {
1379
1393
var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
1380
1394
INHERITED = '"$(inherited)"' ,
1381
1395
config , buildSettings , searchPaths ;
1382
1396
1397
+ productName = unquote ( productName || this . productName ) ;
1398
+
1383
1399
for ( config in configurations ) {
1384
1400
buildSettings = configurations [ config ] . buildSettings ;
1385
1401
1386
- if ( unquote ( buildSettings [ 'PRODUCT_NAME' ] ) != this . productName )
1402
+ if ( unquote ( buildSettings [ 'PRODUCT_NAME' ] ) != productName )
1387
1403
continue ;
1388
1404
1389
1405
if ( ! buildSettings [ 'HEADER_SEARCH_PATHS' ] ) {
0 commit comments