@@ -566,11 +566,22 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
566
566
if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) ) {
567
567
file . uuid = this . generateUuid ( ) ;
568
568
file . fileRef = file . uuid ;
569
- this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
570
- this . addToPbxBuildFileSection ( file ) ;
571
- pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
572
569
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
+ }
574
585
} else if ( isSourceOrHeaderFileType ( file . lastKnownFileType ) ) {
575
586
file . uuid = this . generateUuid ( ) ;
576
587
file . fileRef = this . generateUuid ( ) ;
@@ -1026,7 +1037,7 @@ pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, co
1026
1037
1027
1038
if ( ! fileReference ) continue ;
1028
1039
1029
- var pbxFileObj = new pbxFile ( fileReference . path ) ;
1040
+ var pbxFileObj = new pbxFile ( fileReference . path || "" ) ;
1030
1041
1031
1042
filePathToBuildFile [ fileReference . path ] = { uuid : buildFileKey , basename : pbxFileObj . basename , group : pbxFileObj . group } ;
1032
1043
}
@@ -1202,13 +1213,13 @@ pbxProject.prototype.buildPhaseObject = function(name, group, target) {
1202
1213
return null ;
1203
1214
}
1204
1215
1205
- pbxProject . prototype . addBuildProperty = function ( prop , value , build_name ) {
1216
+ pbxProject . prototype . addBuildProperty = function ( prop , value , build_name , productName ) {
1206
1217
var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
1207
1218
key , configuration ;
1208
1219
1209
1220
for ( key in configurations ) {
1210
1221
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 } "` ) ) {
1212
1223
configuration . buildSettings [ prop ] = value ;
1213
1224
}
1214
1225
}
@@ -1515,7 +1526,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) {
1515
1526
isa : 'XCBuildConfiguration' ,
1516
1527
buildSettings : {
1517
1528
GCC_PREPROCESSOR_DEFINITIONS : [ '"DEBUG=1"' , '"$(inherited)"' ] ,
1518
- INFOPLIST_FILE : '"' + $path . join ( targetSubfolder , targetSubfolder + '- Info.plist' + '"' ) ,
1529
+ INFOPLIST_FILE : '"' + $path . join ( targetSubfolder , ' Info.plist' + '"' ) ,
1519
1530
LD_RUNPATH_SEARCH_PATHS : '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"' ,
1520
1531
PRODUCT_NAME : '"' + targetName + '"' ,
1521
1532
SKIP_INSTALL : 'YES'
@@ -1525,7 +1536,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder) {
1525
1536
name : 'Release' ,
1526
1537
isa : 'XCBuildConfiguration' ,
1527
1538
buildSettings : {
1528
- INFOPLIST_FILE : '"' + $path . join ( targetSubfolder , targetSubfolder + '- Info.plist' + '"' ) ,
1539
+ INFOPLIST_FILE : '"' + $path . join ( targetSubfolder , ' Info.plist' + '"' ) ,
1529
1540
LD_RUNPATH_SEARCH_PATHS : '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"' ,
1530
1541
PRODUCT_NAME : '"' + targetName + '"' ,
1531
1542
SKIP_INSTALL : 'YES'
@@ -2037,16 +2048,24 @@ pbxProject.prototype.findPBXVariantGroupKey = function(criteria) {
2037
2048
return this . findPBXGroupKeyAndType ( criteria , 'PBXVariantGroup' ) ;
2038
2049
}
2039
2050
2040
- pbxProject . prototype . addLocalizationVariantGroup = function ( name ) {
2051
+ pbxProject . prototype . addLocalizationVariantGroup = function ( name , ops ) {
2052
+ ops = ops || { } ;
2041
2053
var groupKey = this . pbxCreateVariantGroup ( name ) ;
2042
2054
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
+ }
2045
2059
2046
2060
var localizationVariantGroup = {
2047
2061
uuid : this . generateUuid ( ) ,
2048
2062
fileRef : groupKey ,
2049
- basename : name
2063
+ basename : name ,
2064
+ group : "Resources" ,
2065
+ children : [ ]
2066
+ }
2067
+ if ( ops . target ) {
2068
+ localizationVariantGroup . target = ops . target ;
2050
2069
}
2051
2070
this . addToPbxBuildFileSection ( localizationVariantGroup ) ; // PBXBuildFile
2052
2071
this . addToPbxResourcesBuildPhase ( localizationVariantGroup ) ; //PBXResourcesBuildPhase
0 commit comments