@@ -26,7 +26,9 @@ var util = require('util'),
2626 isSourceFileType = require ( './pbxFile' ) . isSourceFileType ,
2727 isHeaderFileType = require ( './pbxFile' ) . isHeaderFileType ,
2828 isResource = require ( './pbxFile' ) . isResource ,
29- isEntitlement = require ( './pbxFile' ) . isEntitlement
29+ isEntitlement = require ( './pbxFile' ) . isEntitlement ,
30+ isAssetFileType = require ( './pbxFile' ) . isAssetFileType ,
31+ isPlist = require ( './pbxFile' ) . isPlist ,
3032 fs = require ( 'fs' ) ,
3133 parser = require ( './parser/pbxproj' ) ,
3234 plist = require ( 'simple-plist' ) ,
@@ -566,18 +568,11 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
566568 if ( opt . target ) {
567569 file . target = opt . target ;
568570 }
569- if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) ) {
571+ if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) && ! isAssetFileType ( file . lastKnownFileType ) ) {
570572 file . fileRef = file . uuid ;
571573 var files = fs . readdirSync ( filePath ) . map ( p => $path . join ( filePath , p ) ) ;
572574 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 ) ;
581576 } else {
582577 this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
583578 this . addToPbxBuildFileSection ( file ) ;
@@ -587,18 +582,22 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
587582 } else {
588583 this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
589584 pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
590- if ( isHeaderFileType ( file . lastKnownFileType ) ) {
585+ if ( isHeaderFileType ( file . lastKnownFileType ) || isPlist ( file . lastKnownFileType ) ) {
591586 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 ) ) {
596590 this . addToBuildSettings ( 'CODE_SIGN_ENTITLEMENTS' , file . path , opt . target ) ;
591+ continue ;
592+ }
593+
594+ if ( isSourceFileType ( file . lastKnownFileType ) ) { // PBXBuildFile
595+ this . addToPbxSourcesBuildPhase ( file ) ;
597596 } else if ( isResource ( file . group ) ) {
598597 this . addToPbxResourcesBuildPhase ( file )
599- } else {
600- this . addToPbxBuildFileSection ( file ) ;
601598 }
599+
600+ this . addToPbxBuildFileSection ( file ) ;
602601 }
603602 }
604603
@@ -619,6 +618,21 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
619618 return { uuid : pbxGroupUuid , pbxGroup : pbxGroup } ;
620619}
621620
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+
622636pbxProject . prototype . removePbxGroup = function ( groupName , path ) {
623637 var group = this . pbxGroupByName ( groupName ) ;
624638 if ( ! group ) {
@@ -1375,15 +1389,17 @@ pbxProject.prototype.removeFromHeaderSearchPaths = function(file) {
13751389
13761390 }
13771391}
1378- pbxProject . prototype . addToHeaderSearchPaths = function ( file ) {
1392+ pbxProject . prototype . addToHeaderSearchPaths = function ( file , productName ) {
13791393 var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
13801394 INHERITED = '"$(inherited)"' ,
13811395 config , buildSettings , searchPaths ;
13821396
1397+ productName = unquote ( productName || this . productName ) ;
1398+
13831399 for ( config in configurations ) {
13841400 buildSettings = configurations [ config ] . buildSettings ;
13851401
1386- if ( unquote ( buildSettings [ 'PRODUCT_NAME' ] ) != this . productName )
1402+ if ( unquote ( buildSettings [ 'PRODUCT_NAME' ] ) != productName )
13871403 continue ;
13881404
13891405 if ( ! buildSettings [ 'HEADER_SEARCH_PATHS' ] ) {
0 commit comments