Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/pbxProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -1700,11 +1700,12 @@ pbxProject.prototype.getFileKey = function(filePath) {
return false;
}

pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {
pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget, productTargetType) {

// Setup uuid and name of new target
var targetUuid = this.generateUuid(),
targetType = type,
productTargetType = productTargetType || targetType,
targetSubfolder = subfolder || name,
targetName = name.trim();

Expand Down Expand Up @@ -1753,7 +1754,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {

// Product: Create
var productName = targetName,
productType = producttypeForTargettype(targetType),
productType = producttypeForTargettype(productTargetType),
productFileType = filetypeForProducttype(productType),
productFile = this.addProductFile(productName, { group: 'Copy Files', 'target': targetUuid, 'explicitFileType': productFileType}),
productFileName = productFile.basename;
Expand Down Expand Up @@ -1781,18 +1782,18 @@ pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {
// Target: Add to PBXNativeTarget section
this.addToPbxNativeTargetSection(target);

if (targetType === 'app_extension' || targetType === 'watch_extension' || targetType === 'watch_app') {
const isWatchApp = targetType === 'watch_app';
if (productTargetType === 'app_extension' || productTargetType === 'watch_extension' || productTargetType === 'watch_app') {
const isWatchApp = productTargetType === 'watch_app';
const copyTargetUuid = parentTarget || this.getFirstTarget().uuid;
const phaseComment = targetType === 'watch_app' ? 'Embed Watch Content' : 'Copy Files';
const phaseComment = productTargetType === 'watch_app' ? 'Embed Watch Content' : 'Copy Files';
let destination;

if(isWatchApp) {
destination = '"$(CONTENTS_FOLDER_PATH)/Watch"';
}

// Create CopyFiles phase in parent target
this.addBuildPhase([], 'PBXCopyFilesBuildPhase', phaseComment, copyTargetUuid, targetType, destination);
this.addBuildPhase([], 'PBXCopyFilesBuildPhase', phaseComment, copyTargetUuid, productTargetType, destination);

// Add product to CopyFiles phase
this.addToPbxCopyfilesBuildPhase(productFile, phaseComment, copyTargetUuid);
Expand Down