Skip to content

Commit 90e4131

Browse files
committed
Add fixes for new addTarget() helper function.
1 parent 8eb7b5d commit 90e4131

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/pbxProject.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,21 +1051,23 @@ pbxProject.prototype.addTarget = function(name, type) {
10511051
];
10521052

10531053
// Build Configuration: Add
1054-
var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName +'"'),
1055-
buildConfigurationsUuid = buildConfigurations.uuid;
1054+
var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName +'"');
10561055

10571056
// Product: Create
10581057
var productName = targetName,
10591058
productType = producttypeForTargettype(targetType),
1060-
productFile = this.addProductFile(productName, { 'explicitFileType': productType }),
1059+
productFileType = filetypeForProducttype(productType),
1060+
productFile = this.addProductFile(productName, { 'target': targetUuid, 'group': 'CopyFiles' }),
10611061
productFileName = productFile.basename;
10621062

1063-
// Product: Embed in first target (only for "extension"-type targets)
1063+
// Product: Embed (only for "extension"-type targets)
10641064
if (targetType === 'app_extension') {
1065-
var embedPhase;
1066-
var embedFile;
10671065

1068-
// TODO: Add embedding via "PBXCopyFilesBuildPhase" build phase
1066+
// Create "Copy Files" build phase for target which contains the extension
1067+
this.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'CopyFiles', this.getFirstTarget().uuid)
1068+
1069+
// Add product reference to "Copy Files" build phase
1070+
this.addCopyfile(productFileName, { 'explicitFileType': productFileType, 'target': this.getFirstTarget().uuid })
10691071
};
10701072

10711073
// Target: Create
@@ -1077,7 +1079,7 @@ pbxProject.prototype.addTarget = function(name, type) {
10771079
productName: targetName,
10781080
productReference: productFile.fileRef,
10791081
productType: '"' + producttypeForTargettype(targetType) + '"',
1080-
buildConfigurationList: buildConfigurationsUuid,
1082+
buildConfigurationList: buildConfigurations.uuid,
10811083
buildPhases: [],
10821084
buildRules: [],
10831085
dependencies: []

test/addTargetDependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ exports.addTargetDependency = {
4040
test.done();
4141
},
4242
'should add targetDependencies to target': function (test) {
43-
var targetInPbxProj = proj.pbxNativeTarget()['1D6058900D05DD3D006BFB55'];
43+
var targetInPbxProj = proj.pbxNativeTargetSection()['1D6058900D05DD3D006BFB55'];
4444
test.deepEqual(targetInPbxProj.dependencies, []);
4545

4646
var target = proj.addTargetDependency('1D6058900D05DD3D006BFB55', ['1D6058900D05DD3D006BFB54', '1D6058900D05DD3D006BFB55']).target;

0 commit comments

Comments
 (0)