@@ -566,11 +566,22 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
566566 if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) ) {
567567 file . uuid = this . generateUuid ( ) ;
568568 file . fileRef = file . uuid ;
569- this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
570- this . addToPbxBuildFileSection ( file ) ;
571- pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
572569 var files = fs . readdirSync ( filePath ) . map ( p => $path . join ( filePath , p ) ) ;
573- this . addPbxGroup ( files , $path . basename ( filePath ) , filePath , null , { uuid : file . uuid , filesRelativeToProject : opt . filesRelativeToProject , target : opt . target } ) ;
570+ if ( $path . extname ( filePath ) === ".lproj" ) {
571+ for ( var i = 0 ; i < files . length ; i ++ ) {
572+ var variantGroup = this . addLocalizationVariantGroup ( $path . basename ( files [ i ] ) , { target : opt . target , skipAddToResourcesGroup : true } ) ;
573+ var refFile = new pbxFile ( $path . relative ( srcRootPath , files [ i ] ) , { basename : $path . parse ( file . basename ) . name } ) ;
574+ refFile . fileRef = this . generateUuid ( ) ;
575+ this . addToPbxFileReferenceSection ( refFile ) ;
576+ this . addToPbxVariantGroup ( refFile , variantGroup . fileRef ) ;
577+ pbxGroup . children . push ( pbxGroupChild ( variantGroup ) ) ;
578+ }
579+ } else {
580+ this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
581+ this . addToPbxBuildFileSection ( file ) ;
582+ pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
583+ this . addPbxGroup ( files , $path . basename ( filePath ) , filePath , null , { uuid : file . uuid , filesRelativeToProject : opt . filesRelativeToProject , target : opt . target } ) ;
584+ }
574585 } else if ( isSourceOrHeaderFileType ( file . lastKnownFileType ) ) {
575586 file . uuid = this . generateUuid ( ) ;
576587 file . fileRef = this . generateUuid ( ) ;
@@ -1026,7 +1037,7 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co
10261037
10271038 if ( ! fileReference ) continue ;
10281039
1029- var pbxFileObj = new pbxFile ( fileReference . path ) ;
1040+ var pbxFileObj = new pbxFile ( fileReference . path || "" ) ;
10301041
10311042 filePathToBuildFile [ fileReference . path ] = { uuid : buildFileKey , basename : pbxFileObj . basename , group : pbxFileObj . group } ;
10321043 }
@@ -1202,13 +1213,13 @@ pbxProject.prototype.buildPhaseObject = function(name, group, target) {
12021213 return null ;
12031214}
12041215
1205- pbxProject . prototype . addBuildProperty = function ( prop , value , build_name ) {
1216+ pbxProject . prototype . addBuildProperty = function ( prop , value , build_name , productName ) {
12061217 var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
12071218 key , configuration ;
12081219
12091220 for ( key in configurations ) {
12101221 configuration = configurations [ key ] ;
1211- if ( ! build_name || configuration . name === build_name ) {
1222+ if ( ( ! build_name || configuration . name === build_name ) && ( ! productName || configuration . buildSettings . PRODUCT_NAME === productName || configuration . buildSettings . PRODUCT_NAME === `" ${ productName } "` ) ) {
12121223 configuration . buildSettings [ prop ] = value ;
12131224 }
12141225 }
@@ -1515,7 +1526,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) {
15151526 isa : 'XCBuildConfiguration' ,
15161527 buildSettings : {
15171528 GCC_PREPROCESSOR_DEFINITIONS : [ '"DEBUG=1"' , '"$(inherited)"' ] ,
1518- INFOPLIST_FILE : '"' + $path . join ( targetSubfolder , targetSubfolder + '- Info.plist' + '"' ) ,
1529+ INFOPLIST_FILE : '"' + $path . join ( targetSubfolder , ' Info.plist' + '"' ) ,
15191530 LD_RUNPATH_SEARCH_PATHS : '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"' ,
15201531 PRODUCT_NAME : '"' + targetName + '"' ,
15211532 SKIP_INSTALL : 'YES'
@@ -1525,7 +1536,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) {
15251536 name : 'Release' ,
15261537 isa : 'XCBuildConfiguration' ,
15271538 buildSettings : {
1528- INFOPLIST_FILE : '"' + $path . join ( targetSubfolder , targetSubfolder + '- Info.plist' + '"' ) ,
1539+ INFOPLIST_FILE : '"' + $path . join ( targetSubfolder , ' Info.plist' + '"' ) ,
15291540 LD_RUNPATH_SEARCH_PATHS : '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"' ,
15301541 PRODUCT_NAME : '"' + targetName + '"' ,
15311542 SKIP_INSTALL : 'YES'
@@ -2037,16 +2048,24 @@ pbxProject.prototype.findPBXVariantGroupKey = function(criteria) {
20372048 return this . findPBXGroupKeyAndType ( criteria , 'PBXVariantGroup' ) ;
20382049}
20392050
2040- pbxProject . prototype . addLocalizationVariantGroup = function ( name ) {
2051+ pbxProject . prototype . addLocalizationVariantGroup = function ( name , ops ) {
2052+ ops = ops || { } ;
20412053 var groupKey = this . pbxCreateVariantGroup ( name ) ;
20422054
2043- var resourceGroupKey = this . findPBXGroupKey ( { name : 'Resources' } ) ;
2044- this . addToPbxGroup ( groupKey , resourceGroupKey ) ;
2055+ if ( ! ops . skipAddToResourcesGroup ) {
2056+ var resourcesGroupKey = this . findPBXGroupKey ( { name : 'Resources' } ) ;
2057+ this . addToPbxGroup ( groupKey , resourcesGroupKey ) ;
2058+ }
20452059
20462060 var localizationVariantGroup = {
20472061 uuid : this . generateUuid ( ) ,
20482062 fileRef : groupKey ,
2049- basename : name
2063+ basename : name ,
2064+ group : "Resources" ,
2065+ children : [ ]
2066+ }
2067+ if ( ops . target ) {
2068+ localizationVariantGroup . target = ops . target ;
20502069 }
20512070 this . addToPbxBuildFileSection ( localizationVariantGroup ) ; // PBXBuildFile
20522071 this . addToPbxResourcesBuildPhase ( localizationVariantGroup ) ; //PBXResourcesBuildPhase
0 commit comments