Skip to content

Commit fb628c6

Browse files
SergeySergey
authored andcommitted
pbxProject removeTargetAttribute
1 parent c78d781 commit fb628c6

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

lib/pbxProject.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,4 +1918,13 @@ pbxProject.prototype.addTargetAttribute = function(prop, value, target) {
19181918
attributes['TargetAttributes'][target.uuid][prop] = value;
19191919
}
19201920

1921+
pbxProject.prototype.removeTargetAttribute = function(prop, target) {
1922+
var attributes = this.getFirstProject()['firstProject']['attributes'];
1923+
target = target || this.getFirstTarget();
1924+
if (attributes['TargetAttributes'] &&
1925+
attributes['TargetAttributes'][target.uuid]) {
1926+
delete attributes['TargetAttributes'][target.uuid][prop];
1927+
}
1928+
}
1929+
19211930
module.exports = pbxProject;

test/group.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,34 @@ exports.testWritingPBXProject = {
346346

347347
test.done();
348348
},
349-
'should successfully add target attribute to PBXProject TargetAttributes': function(test) {
350-
console.log(project.addTargetAttribute);
349+
'should add target attribute to PBXProject TargetAttributes': function(test) {
351350
project.addTargetAttribute('ProvisioningStyle', 'Manual');
351+
var output = project.writeSync();
352+
test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
353+
354+
test.done();
355+
},
356+
'should change target attribute at PBXProject TargetAttributes': function(test) {
357+
project.addTargetAttribute('ProvisioningStyle', 'Manual');
358+
var output = project.writeSync();
359+
test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
360+
361+
project.addTargetAttribute('ProvisioningStyle', 'Automatic');
362+
output = project.writeSync();
363+
test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g), null);
364+
test.equal(output.match(/ProvisioningStyle\s*=\s*Automatic/g).length, 1);
352365

366+
test.done();
367+
},
368+
'should remove target attribute from PBXProject TargetAttributes': function(test) {
369+
project.addTargetAttribute('ProvisioningStyle', 'Manual');
353370
var output = project.writeSync();
354-
console.log(output);
355371
test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g).length, 1);
372+
373+
project.removeTargetAttribute('ProvisioningStyle');
374+
output = project.writeSync();
375+
test.equal(output.match(/ProvisioningStyle\s*=\s*Manual/g), null);
376+
356377
test.done();
357378
}
358379
}

0 commit comments

Comments
 (0)