@@ -23,9 +23,10 @@ var util = require('util'),
23
23
fork = require ( 'child_process' ) . fork ,
24
24
pbxWriter = require ( './pbxWriter' ) ,
25
25
pbxFile = require ( './pbxFile' ) . pbxFile ,
26
- isSourceOrHeaderFileType = require ( './pbxFile' ) . isSourceOrHeaderFileType ,
26
+ isSourceFileType = require ( './pbxFile' ) . isSourceFileType ,
27
27
isHeaderFileType = require ( './pbxFile' ) . isHeaderFileType ,
28
28
isResource = require ( './pbxFile' ) . isResource ,
29
+ isEntitlement = require ( './pbxFile' ) . isEntitlement
29
30
fs = require ( 'fs' ) ,
30
31
parser = require ( './parser/pbxproj' ) ,
31
32
plist = require ( 'simple-plist' ) ,
@@ -560,13 +561,12 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
560
561
var srcRootPath = $path . dirname ( $path . dirname ( this . filepath ) ) ;
561
562
var relativePath = $path . relative ( srcRootPath , filePath ) ;
562
563
var file = new pbxFile ( opt . filesRelativeToProject ? relativePath : filePath ) ;
563
-
564
+ file . uuid = this . generateUuid ( ) ;
565
+ file . fileRef = this . generateUuid ( ) ;
564
566
if ( opt . target ) {
565
567
file . target = opt . target ;
566
568
}
567
-
568
569
if ( fs . existsSync ( filePath ) && fs . lstatSync ( filePath ) . isDirectory ( ) ) {
569
- file . uuid = this . generateUuid ( ) ;
570
570
file . fileRef = file . uuid ;
571
571
var files = fs . readdirSync ( filePath ) . map ( p => $path . join ( filePath , p ) ) ;
572
572
if ( $path . extname ( filePath ) === ".lproj" ) {
@@ -584,27 +584,21 @@ pbxProject.prototype.addPbxGroup = function (filePathsArray, name, path, sourceT
584
584
pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
585
585
this . addPbxGroup ( files , $path . basename ( filePath ) , filePath , null , { uuid : file . uuid , filesRelativeToProject : opt . filesRelativeToProject , target : opt . target } ) ;
586
586
}
587
- } else if ( isSourceOrHeaderFileType ( file . lastKnownFileType ) ) {
588
- file . uuid = this . generateUuid ( ) ;
589
- file . fileRef = this . generateUuid ( ) ;
590
- this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
591
- this . addToPbxBuildFileSection ( file ) ; // PBXBuildFile
592
- if ( ! isHeaderFileType ( file . lastKnownFileType ) ) {
593
- this . addToPbxSourcesBuildPhase ( file ) ;
594
- }
595
- pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
596
- } else if ( isResource ( file . group ) ) {
597
- file . uuid = this . generateUuid ( ) ;
598
- file . fileRef = this . generateUuid ( ) ;
599
- this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
600
- this . addToPbxResourcesBuildPhase ( file )
601
- pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
602
587
} else {
603
- file . uuid = this . generateUuid ( ) ;
604
- file . fileRef = this . generateUuid ( ) ;
605
588
this . addToPbxFileReferenceSection ( file ) ; // PBXFileReference
606
- this . addToPbxBuildFileSection ( file ) ;
607
589
pbxGroup . children . push ( pbxGroupChild ( file ) ) ;
590
+ if ( isHeaderFileType ( file . lastKnownFileType ) ) {
591
+ continue ;
592
+ } else if ( isSourceFileType ( file . lastKnownFileType ) ) {
593
+ this . addToPbxBuildFileSection ( file ) ; // PBXBuildFile
594
+ this . addToPbxSourcesBuildPhase ( file ) ;
595
+ } else if ( isEntitlement ( file . lastKnownFileType ) ) {
596
+ this . addToBuildSettings ( 'CODE_SIGN_ENTITLEMENTS' , file . path , opt . target ) ;
597
+ } else if ( isResource ( file . group ) ) {
598
+ this . addToPbxResourcesBuildPhase ( file )
599
+ } else {
600
+ this . addToPbxBuildFileSection ( file ) ;
601
+ }
608
602
}
609
603
}
610
604
@@ -1445,14 +1439,30 @@ pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) {
1445
1439
}
1446
1440
}
1447
1441
1448
- pbxProject . prototype . addToBuildSettings = function ( buildSetting , value ) {
1442
+ pbxProject . prototype . addToBuildSettings = function ( buildSetting , value , targetUuid ) {
1449
1443
var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
1444
+ buildConfigurationsUuids = [ ] ,
1450
1445
config , buildSettings ;
1451
1446
1447
+ if ( targetUuid ) {
1448
+ var targets = this . hash . project . objects [ 'PBXNativeTarget' ] || [ ] ;
1449
+ var target = targets [ targetUuid ] || { } ;
1450
+ var buildConfigurationList = target [ "buildConfigurationList" ] ;
1451
+ var pbxXCConfigurationListSection = this . pbxXCConfigurationList ( ) || { } ;
1452
+ var xcConfigurationList = pbxXCConfigurationListSection [ buildConfigurationList ] || { } ;
1453
+ var buildConfigurations = xcConfigurationList . buildConfigurations || [ ] ;
1454
+ for ( var configurationUuid in buildConfigurations ) {
1455
+ buildConfigurationsUuids . push ( buildConfigurations [ configurationUuid ] . value ) ;
1456
+ }
1457
+
1458
+ }
1459
+
1452
1460
for ( config in configurations ) {
1453
- buildSettings = configurations [ config ] . buildSettings ;
1461
+ if ( ! target || buildConfigurationsUuids . indexOf ( config ) >= 0 ) {
1462
+ buildSettings = configurations [ config ] . buildSettings ;
1454
1463
1455
- buildSettings [ buildSetting ] = value ;
1464
+ buildSettings [ buildSetting ] = value ;
1465
+ }
1456
1466
}
1457
1467
}
1458
1468
@@ -1762,9 +1772,15 @@ pbxProject.prototype.removeTarget = function(target, targetKey) {
1762
1772
}
1763
1773
}
1764
1774
1775
+ //remove targetAttributes for target
1776
+ var attributes = this . getFirstProject ( ) [ 'firstProject' ] [ 'attributes' ] ;
1777
+ if ( attributes [ 'TargetAttributes' ] ) {
1778
+ delete attributes [ 'TargetAttributes' ] [ targetKey ] ;
1779
+ }
1780
+
1765
1781
//remove the target from PBXNativeTarget section
1766
1782
var nativeTargets = this . pbxNativeTargetSection ( ) ;
1767
- removeItemAndCommentFromSectionByUuid ( nativeTargets , nativeTargetUuid ) ;
1783
+ removeItemAndCommentFromSectionByUuid ( nativeTargets , targetKey ) ;
1768
1784
1769
1785
this . removePbxGroup ( unquote ( target . name ) ) ;
1770
1786
} ;
0 commit comments