addBuildPhase(): Add ad-hoc creation of "CopyFiles" build phase, as it is not available in empty (Cordova) projects
diff --git a/lib/pbxProject.js b/lib/pbxProject.js
index 6b04eb1..b6cb1dd 100644
--- a/lib/pbxProject.js
+++ b/lib/pbxProject.js
@@ -589,20 +589,46 @@
return { uuid: target, target: nativeTargets[target] };
}
-pbxProject.prototype.addBuildPhase = function (filePathsArray, isa, comment) {
- var section = this.hash.project.objects[isa],
+pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, comment, target, folderType, subfolderPath) {
+ var buildPhaseSection,
fileReferenceSection = this.pbxFileReferenceSection(),
buildFileSection = this.pbxBuildFileSection(),
buildPhaseUuid = this.generateUuid(),
+ buildPhaseTargetUuid = target || this.getFirstTarget().uuid,
commentKey = f("%s_comment", buildPhaseUuid),
buildPhase = {
- isa: isa,
+ isa: buildPhaseType,
buildActionMask: 2147483647,
files: [],
runOnlyForDeploymentPostprocessing: 0
},
filePathToBuildFile = {};
+
+ if (buildPhaseType === 'PBXCopyFilesBuildPhase') {
+ buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, folderType, subfolderPath, comment);
+ buildPhase.name = comment;
+ }
+
+ if (!this.hash.project.objects[buildPhaseType]) {
+ this.hash.project.objects[buildPhaseType] = new Object();
+ this.hash.project.objects[buildPhaseType][buildPhaseUuid] = buildPhase;
+ this.hash.project.objects[buildPhaseType][commentKey] = comment;
+
+
+ this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases'].push({
+ value: buildPhaseUuid,
+ comment: comment
+ })
+
+ console.log(util.inspect(this.hash.project.objects['PBXNativeTarget'], true, null));
+
+ }
+
+
+ buildPhase = this.hash.project.objects[buildPhaseType];
+
+
for (var key in buildFileSection) {
// only look for comments
if (!COMMENT_KEY.test(key)) continue;
@@ -638,9 +664,9 @@
buildPhase.files.push(pbxBuildPhaseObj(file));
}
- if (section) {
- section[buildPhaseUuid] = buildPhase;
- section[commentKey] = comment;
+ if (buildPhaseSection) {
+ buildPhaseSection[buildPhaseUuid] = buildPhase;
+ buildPhaseSection[commentKey] = comment;
}
return { uuid: buildPhaseUuid, buildPhase: buildPhase };