Merge branch 'superserg8-master'
diff --git a/lib/pbxProject.js b/lib/pbxProject.js
index c568e50..13e7246 100644
--- a/lib/pbxProject.js
+++ b/lib/pbxProject.js
@@ -230,7 +230,7 @@
file = this.addPluginFile(path, opt);
if (!file) return false;
} else {
- file = new pbxFile(path, opt);
+ file = new pbxFile(path, opt);
if (this.hasFile(file.path)) return false;
}
@@ -241,10 +241,10 @@
correctForResourcesPath(file, this);
file.fileRef = this.generateUuid();
}
-
+
this.addToPbxBuildFileSection(file); // PBXBuildFile
this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
-
+
if (!opt.plugin) {
this.addToPbxFileReferenceSection(file); // PBXFileReference
if (group) {
@@ -253,9 +253,9 @@
else {
this.addToResourcesPbxGroup(file); // PBXGroup
}
-
+
}
-
+
return file;
}
@@ -279,7 +279,7 @@
}
else {
this.removeFromResourcesPbxGroup(file); // PBXGroup
- }
+ }
this.removeFromPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
return file;
@@ -1906,5 +1906,25 @@
return file;
}
+pbxProject.prototype.addTargetAttribute = function(prop, value, target) {
+ var attributes = this.getFirstProject()['firstProject']['attributes'];
+ if (attributes['TargetAttributes'] === undefined) {
+ attributes['TargetAttributes'] = {};
+ }
+ target = target || this.getFirstTarget();
+ if (attributes['TargetAttributes'][target.uuid] === undefined) {
+ attributes['TargetAttributes'][target.uuid] = {};
+ }
+ attributes['TargetAttributes'][target.uuid][prop] = value;
+}
+
+pbxProject.prototype.removeTargetAttribute = function(prop, target) {
+ var attributes = this.getFirstProject()['firstProject']['attributes'];
+ target = target || this.getFirstTarget();
+ if (attributes['TargetAttributes'] &&
+ attributes['TargetAttributes'][target.uuid]) {
+ delete attributes['TargetAttributes'][target.uuid][prop];
+ }
+}
module.exports = pbxProject;
diff --git a/test/group.js b/test/group.js
index 8eb5b00..b907c7e 100644
--- a/test/group.js
+++ b/test/group.js
@@ -215,7 +215,7 @@
exports.addResourceFileToGroup = {
'should add resource file (PNG) to the splash group' : function(test) {
-
+
var testKey = project.findPBXGroupKey({path:'splash'});
var file = project.addResourceFile('DefaultTest-667h.png', {}, testKey);
@@ -311,7 +311,6 @@
}
exports.testWritingPBXProject = {
-
'should successfully write to PBXProject TargetAttributes': function(test) {
var pbxProjectObj = project.getPBXObject('PBXProject');
var pbxProject;
@@ -346,5 +345,35 @@
var output = project.writeSync();
test.done();
+ },
+ 'should add target attribute to PBXProject TargetAttributes': function(test) {
+ project.addTargetAttribute('ProvisioningStyle', 'Manual');
+ var output = project.writeSync();
+ test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
+
+ test.done();
+ },
+ 'should change target attribute at PBXProject TargetAttributes': function(test) {
+ project.addTargetAttribute('ProvisioningStyle', 'Manual');
+ var output = project.writeSync();
+ test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
+
+ project.addTargetAttribute('ProvisioningStyle', 'Automatic');
+ output = project.writeSync();
+ test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g), null);
+ test.equal(output.match(/ProvisioningStyle\s*=\s*Automatic/g).length, 1);
+
+ test.done();
+ },
+ 'should remove target attribute from PBXProject TargetAttributes': function(test) {
+ project.addTargetAttribute('ProvisioningStyle', 'Manual');
+ var output = project.writeSync();
+ test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
+
+ project.removeTargetAttribute('ProvisioningStyle');
+ output = project.writeSync();
+ test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g), null);
+
+ test.done();
}
}