Skip to content

Commit af22109

Browse files
committed
[pbxWriter] handle objects in arrays
1 parent 012d509 commit af22109

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

lib/pbxWriter.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function pbxWriter(contents) {
4040

4141
function escapeInternals(str) {
4242
return str.replace(QUOTED, function (orig, middle) {
43-
return '"' + middle.replace(/"/g, '\\"') + '"';
43+
return f('"%s"', middle.replace(/"/g, '\\"'));
4444
});
4545
}
4646

@@ -191,6 +191,14 @@ pbxWriter.prototype.writeArray = function (arr, name) {
191191

192192
if (entry.value && entry.comment) {
193193
this.write('%s /* %s */,\n', entry.value, entry.comment);
194+
} else if (isObject(entry)) {
195+
this.write('{\n');
196+
this.indentLevel++;
197+
198+
this.writeObject(entry);
199+
200+
this.indentLevel--;
201+
this.write('},\n');
194202
} else {
195203
this.write('%s,\n', entry);
196204
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 45;
7+
objects = {
8+
/* Begin PBXProject section */
9+
29B97313FDCFA39411CA2CEA /* Project object */ = {
10+
isa = PBXProject;
11+
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "KitchenSinktablet" */;
12+
compatibilityVersion = "Xcode 3.1";
13+
developmentRegion = English;
14+
hasScannedForEncodings = 1;
15+
knownRegions = (
16+
English,
17+
Japanese,
18+
French,
19+
German,
20+
en,
21+
es,
22+
);
23+
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
24+
projectDirPath = "";
25+
projectReferences = (
26+
{
27+
ProductGroup = 301BF52E109A57CC0062928A /* Products */;
28+
ProjectRef = 301BF52D109A57CC0062928A /* PhoneGapLib.xcodeproj */;
29+
},
30+
);
31+
projectRoot = "";
32+
targets = (
33+
1D6058900D05DD3D006BFB54 /* KitchenSinktablet */,
34+
);
35+
};
36+
/* End PBXProject section */
37+
};
38+
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
39+
}

test/pbxWriter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@ exports.writeSync = {
5454
},
5555
'should write out the "build-config" test': function (test) {
5656
testProjectContents('test/parser/projects/build-config.pbxproj', test);
57+
},
58+
'should write out the "nested-object" test': function (test) {
59+
testProjectContents('test/parser/projects/nested-object.pbxproj', test);
5760
}
5861
}

0 commit comments

Comments
 (0)