Skip to content

Commit 7f26cc0

Browse files
author
Anis Kadri
committed
Merge branch 'superserg8-master'
2 parents 4cca2f6 + fb628c6 commit 7f26cc0

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

lib/pbxProject.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) {
230230
file = this.addPluginFile(path, opt);
231231
if (!file) return false;
232232
} else {
233-
file = new pbxFile(path, opt);
233+
file = new pbxFile(path, opt);
234234
if (this.hasFile(file.path)) return false;
235235
}
236236

@@ -241,10 +241,10 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) {
241241
correctForResourcesPath(file, this);
242242
file.fileRef = this.generateUuid();
243243
}
244-
244+
245245
this.addToPbxBuildFileSection(file); // PBXBuildFile
246246
this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
247-
247+
248248
if (!opt.plugin) {
249249
this.addToPbxFileReferenceSection(file); // PBXFileReference
250250
if (group) {
@@ -253,9 +253,9 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) {
253253
else {
254254
this.addToResourcesPbxGroup(file); // PBXGroup
255255
}
256-
256+
257257
}
258-
258+
259259
return file;
260260
}
261261

@@ -279,7 +279,7 @@ pbxProject.prototype.removeResourceFile = function(path, opt, group) {
279279
}
280280
else {
281281
this.removeFromResourcesPbxGroup(file); // PBXGroup
282-
}
282+
}
283283
this.removeFromPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
284284

285285
return file;
@@ -1906,5 +1906,25 @@ pbxProject.prototype.addDataModelDocument = function(filePath, group, opt) {
19061906
return file;
19071907
}
19081908

1909+
pbxProject.prototype.addTargetAttribute = function(prop, value, target) {
1910+
var attributes = this.getFirstProject()['firstProject']['attributes'];
1911+
if (attributes['TargetAttributes'] === undefined) {
1912+
attributes['TargetAttributes'] = {};
1913+
}
1914+
target = target || this.getFirstTarget();
1915+
if (attributes['TargetAttributes'][target.uuid] === undefined) {
1916+
attributes['TargetAttributes'][target.uuid] = {};
1917+
}
1918+
attributes['TargetAttributes'][target.uuid][prop] = value;
1919+
}
1920+
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+
}
19091929

19101930
module.exports = pbxProject;

test/group.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ exports.removeHeaderFileFromGroup = {
215215

216216
exports.addResourceFileToGroup = {
217217
'should add resource file (PNG) to the splash group' : function(test) {
218-
218+
219219
var testKey = project.findPBXGroupKey({path:'splash'});
220220
var file = project.addResourceFile('DefaultTest-667h.png', {}, testKey);
221221

@@ -311,7 +311,6 @@ exports.validateHasFile = {
311311
}
312312

313313
exports.testWritingPBXProject = {
314-
315314
'should successfully write to PBXProject TargetAttributes': function(test) {
316315
var pbxProjectObj = project.getPBXObject('PBXProject');
317316
var pbxProject;
@@ -345,6 +344,36 @@ exports.testWritingPBXProject = {
345344

346345
var output = project.writeSync();
347346

347+
test.done();
348+
},
349+
'should add target attribute to PBXProject TargetAttributes': function(test) {
350+
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);
365+
366+
test.done();
367+
},
368+
'should remove target attribute from PBXProject TargetAttributes': function(test) {
369+
project.addTargetAttribute('ProvisioningStyle', 'Manual');
370+
var output = project.writeSync();
371+
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+
348377
test.done();
349378
}
350379
}

0 commit comments

Comments
 (0)