aboutsummaryrefslogtreecommitdiff
path: root/cordova/node_modules/xcode/lib
diff options
context:
space:
mode:
authorKumar Priyansh <[email protected]>2019-01-19 12:37:14 +0530
committerKumar Priyansh <[email protected]>2019-01-19 12:37:14 +0530
commitdcdfc94cb39dfe2c39925a0145ffa45e2d061c30 (patch)
tree4f6379d955555b298c0e7b83a67e264240ee5614 /cordova/node_modules/xcode/lib
parent76f7b3678d3f1ff99c3935a774d420453b0c3cb9 (diff)
downloadWeatherApp-dcdfc94cb39dfe2c39925a0145ffa45e2d061c30.tar.xz
WeatherApp-dcdfc94cb39dfe2c39925a0145ffa45e2d061c30.zip
Initial Upload via GIT
Diffstat (limited to 'cordova/node_modules/xcode/lib')
-rwxr-xr-xcordova/node_modules/xcode/lib/parseJob.js15
-rwxr-xr-xcordova/node_modules/xcode/lib/parser/pbxproj.js1899
-rwxr-xr-xcordova/node_modules/xcode/lib/parser/pbxproj.pegjs263
-rwxr-xr-xcordova/node_modules/xcode/lib/pbxFile.js215
-rwxr-xr-xcordova/node_modules/xcode/lib/pbxProject.js2059
-rwxr-xr-xcordova/node_modules/xcode/lib/pbxWriter.js282
6 files changed, 4733 insertions, 0 deletions
diff --git a/cordova/node_modules/xcode/lib/parseJob.js b/cordova/node_modules/xcode/lib/parseJob.js
new file mode 100755
index 0000000..9d6bffa
--- /dev/null
+++ b/cordova/node_modules/xcode/lib/parseJob.js
@@ -0,0 +1,15 @@
+// parsing is slow and blocking right now
+// so we do it in a separate process
+var fs = require('fs'),
+ parser = require('./parser/pbxproj'),
+ path = process.argv[2],
+ fileContents, obj;
+
+try {
+ fileContents = fs.readFileSync(path, 'utf-8');
+ obj = parser.parse(fileContents);
+ process.send(obj);
+} catch (e) {
+ process.send(e);
+ process.exitCode = 1;
+}
diff --git a/cordova/node_modules/xcode/lib/parser/pbxproj.js b/cordova/node_modules/xcode/lib/parser/pbxproj.js
new file mode 100755
index 0000000..69f2a6a
--- /dev/null
+++ b/cordova/node_modules/xcode/lib/parser/pbxproj.js
@@ -0,0 +1,1899 @@
+/*
+ * Generated by PEG.js 0.10.0.
+ *
+ * http://pegjs.org/
+ */
+
+"use strict";
+
+function peg$subclass(child, parent) {
+ function ctor() { this.constructor = child; }
+ ctor.prototype = parent.prototype;
+ child.prototype = new ctor();
+}
+
+function peg$SyntaxError(message, expected, found, location) {
+ this.message = message;
+ this.expected = expected;
+ this.found = found;
+ this.location = location;
+ this.name = "SyntaxError";
+
+ if (typeof Error.captureStackTrace === "function") {
+ Error.captureStackTrace(this, peg$SyntaxError);
+ }
+}
+
+peg$subclass(peg$SyntaxError, Error);
+
+peg$SyntaxError.buildMessage = function(expected, found) {
+ var DESCRIBE_EXPECTATION_FNS = {
+ literal: function(expectation) {
+ return "\"" + literalEscape(expectation.text) + "\"";
+ },
+
+ "class": function(expectation) {
+ var escapedParts = "",
+ i;
+
+ for (i = 0; i < expectation.parts.length; i++) {
+ escapedParts += expectation.parts[i] instanceof Array
+ ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
+ : classEscape(expectation.parts[i]);
+ }
+
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
+ },
+
+ any: function(expectation) {
+ return "any character";
+ },
+
+ end: function(expectation) {
+ return "end of input";
+ },
+
+ other: function(expectation) {
+ return expectation.description;
+ }
+ };
+
+ function hex(ch) {
+ return ch.charCodeAt(0).toString(16).toUpperCase();
+ }
+
+ function literalEscape(s) {
+ return s
+ .replace(/\\/g, '\\\\')
+ .replace(/"/g, '\\"')
+ .replace(/\0/g, '\\0')
+ .replace(/\t/g, '\\t')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
+ }
+
+ function classEscape(s) {
+ return s
+ .replace(/\\/g, '\\\\')
+ .replace(/\]/g, '\\]')
+ .replace(/\^/g, '\\^')
+ .replace(/-/g, '\\-')
+ .replace(/\0/g, '\\0')
+ .replace(/\t/g, '\\t')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
+ }
+
+ function describeExpectation(expectation) {
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
+ }
+
+ function describeExpected(expected) {
+ var descriptions = new Array(expected.length),
+ i, j;
+
+ for (i = 0; i < expected.length; i++) {
+ descriptions[i] = describeExpectation(expected[i]);
+ }
+
+ descriptions.sort();
+
+ if (descriptions.length > 0) {
+ for (i = 1, j = 1; i < descriptions.length; i++) {
+ if (descriptions[i - 1] !== descriptions[i]) {
+ descriptions[j] = descriptions[i];
+ j++;
+ }
+ }
+ descriptions.length = j;
+ }
+
+ switch (descriptions.length) {
+ case 1:
+ return descriptions[0];
+
+ case 2:
+ return descriptions[0] + " or " + descriptions[1];
+
+ default:
+ return descriptions.slice(0, -1).join(", ")
+ + ", or "
+ + descriptions[descriptions.length - 1];
+ }
+ }
+
+ function describeFound(found) {
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
+ }
+
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
+};
+
+function peg$parse(input, options) {
+ options = options !== void 0 ? options : {};
+
+ var peg$FAILED = {},
+
+ peg$startRuleFunctions = { Project: peg$parseProject },
+ peg$startRuleFunction = peg$parseProject,
+
+ peg$c0 = function(headComment, obj) {
+ var proj = Object.create(null)
+ proj.project = obj
+
+ if (headComment) {
+ proj.headComment = headComment
+ }
+
+ return proj;
+ },
+ peg$c1 = "{",
+ peg$c2 = peg$literalExpectation("{", false),
+ peg$c3 = "}",
+ peg$c4 = peg$literalExpectation("}", false),
+ peg$c5 = function(obj) { return obj },
+ peg$c6 = function() { return Object.create(null) },
+ peg$c7 = function(list) {
+ var returnObject = list[0][0];
+ for(var i = 1; i < list.length; i++){
+ var another = list[i][0];
+ returnObject = merge_obj(returnObject, another);
+ }
+ return returnObject;
+ },
+ peg$c8 = "=",
+ peg$c9 = peg$literalExpectation("=", false),
+ peg$c10 = ";",
+ peg$c11 = peg$literalExpectation(";", false),
+ peg$c12 = function(id, val) {
+ var result = Object.create(null);
+ result[id] = val
+ return result
+ },
+ peg$c13 = function(commentedId, val) {
+ var result = Object.create(null),
+ commentKey = commentedId.id + '_comment';
+
+ result[commentedId.id] = val;
+ result[commentKey] = commentedId[commentKey];
+ return result;
+
+ },
+ peg$c14 = function(id, commentedVal) {
+ var result = Object.create(null);
+ result[id] = commentedVal.value;
+ result[id + "_comment"] = commentedVal.comment;
+ return result;
+ },
+ peg$c15 = function(id, comment) {
+ var result = Object.create(null);
+ result.id = id;
+ result[id + "_comment"] = comment.trim();
+ return result
+ },
+ peg$c16 = function(literal, comment) {
+ var result = Object.create(null)
+ result.comment = comment.trim();
+ result.value = literal.trim();
+ return result;
+ },
+ peg$c17 = /^[^*]/,
+ peg$c18 = peg$classExpectation(["*"], true, false),
+ peg$c19 = function(body) { return body.join('') },
+ peg$c20 = "/*",
+ peg$c21 = peg$literalExpectation("/*", false),
+ peg$c22 = "*/",
+ peg$c23 = peg$literalExpectation("*/", false),
+ peg$c24 = function(begin, fields) {
+ var section = Object.create(null);
+ section[begin.name] = fields
+
+ return section
+ },
+ peg$c25 = "/* Begin ",
+ peg$c26 = peg$literalExpectation("/* Begin ", false),
+ peg$c27 = " section */",
+ peg$c28 = peg$literalExpectation(" section */", false),
+ peg$c29 = function(sectionName) { return { name: sectionName } },
+ peg$c30 = "/* End ",
+ peg$c31 = peg$literalExpectation("/* End ", false),
+ peg$c32 = "(",
+ peg$c33 = peg$literalExpectation("(", false),
+ peg$c34 = ")",
+ peg$c35 = peg$literalExpectation(")", false),
+ peg$c36 = function(arr) { return arr },
+ peg$c37 = function() { return [] },
+ peg$c38 = function(head, tail) {
+ if (tail) {
+ tail.unshift(head);
+ return tail;
+ } else {
+ return [head];
+ }
+ },
+ peg$c39 = function(val) { return val },
+ peg$c40 = function(val, comment) {
+ var result = Object.create(null);
+ result.value = val.trim();
+ result.comment = comment.trim();
+ return result;
+ },
+ peg$c41 = ",",
+ peg$c42 = peg$literalExpectation(",", false),
+ peg$c43 = /^[A-Za-z0-9_.]/,
+ peg$c44 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_", "."], false, false),
+ peg$c45 = function(id) { return id.join('') },
+ peg$c46 = ".",
+ peg$c47 = peg$literalExpectation(".", false),
+ peg$c48 = function(decimal) {
+ // store decimals as strings
+ // as JS doesn't differentiate bw strings and numbers
+ return decimal.join('')
+ },
+ peg$c49 = function(number) { return parseInt(number.join(''), 10) },
+ peg$c50 = function(str) { return '"' + str + '"' },
+ peg$c51 = function(str) { return str.join('') },
+ peg$c52 = peg$anyExpectation(),
+ peg$c53 = function(char) { return char },
+ peg$c54 = "\\",
+ peg$c55 = peg$literalExpectation("\\", false),
+ peg$c56 = function() { return '\\"' },
+ peg$c57 = function(literal) { return literal.join('') },
+ peg$c58 = /^[^;,\n]/,
+ peg$c59 = peg$classExpectation([";", ",", "\n"], true, false),
+ peg$c60 = "//",
+ peg$c61 = peg$literalExpectation("//", false),
+ peg$c62 = function(contents) { return contents },
+ peg$c63 = function(contents) { return contents.join('') },
+ peg$c64 = /^[0-9]/,
+ peg$c65 = peg$classExpectation([["0", "9"]], false, false),
+ peg$c66 = /^[A-Za-z]/,
+ peg$c67 = peg$classExpectation([["A", "Z"], ["a", "z"]], false, false),
+ peg$c68 = "\"",
+ peg$c69 = peg$literalExpectation("\"", false),
+ peg$c70 = peg$otherExpectation("whitespace"),
+ peg$c71 = /^[\t ]/,
+ peg$c72 = peg$classExpectation(["\t", " "], false, false),
+ peg$c73 = /^[\n\r]/,
+ peg$c74 = peg$classExpectation(["\n", "\r"], false, false),
+
+ peg$currPos = 0,
+ peg$savedPos = 0,
+ peg$posDetailsCache = [{ line: 1, column: 1 }],
+ peg$maxFailPos = 0,
+ peg$maxFailExpected = [],
+ peg$silentFails = 0,
+
+ peg$result;
+
+ if ("startRule" in options) {
+ if (!(options.startRule in peg$startRuleFunctions)) {
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
+ }
+
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
+ }
+
+ function text() {
+ return input.substring(peg$savedPos, peg$currPos);
+ }
+
+ function location() {
+ return peg$computeLocation(peg$savedPos, peg$currPos);
+ }
+
+ function expected(description, location) {
+ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
+
+ throw peg$buildStructuredError(
+ [peg$otherExpectation(description)],
+ input.substring(peg$savedPos, peg$currPos),
+ location
+ );
+ }
+
+ function error(message, location) {
+ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
+
+ throw peg$buildSimpleError(message, location);
+ }
+
+ function peg$literalExpectation(text, ignoreCase) {
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
+ }
+
+ function peg$classExpectation(parts, inverted, ignoreCase) {
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
+ }
+
+ function peg$anyExpectation() {
+ return { type: "any" };
+ }
+
+ function peg$endExpectation() {
+ return { type: "end" };
+ }
+
+ function peg$otherExpectation(description) {
+ return { type: "other", description: description };
+ }
+
+ function peg$computePosDetails(pos) {
+ var details = peg$posDetailsCache[pos], p;
+
+ if (details) {
+ return details;
+ } else {
+ p = pos - 1;
+ while (!peg$posDetailsCache[p]) {
+ p--;
+ }
+
+ details = peg$posDetailsCache[p];
+ details = {
+ line: details.line,
+ column: details.column
+ };
+
+ while (p < pos) {
+ if (input.charCodeAt(p) === 10) {
+ details.line++;
+ details.column = 1;
+ } else {
+ details.column++;
+ }
+
+ p++;
+ }
+
+ peg$posDetailsCache[pos] = details;
+ return details;
+ }
+ }
+
+ function peg$computeLocation(startPos, endPos) {
+ var startPosDetails = peg$computePosDetails(startPos),
+ endPosDetails = peg$computePosDetails(endPos);
+
+ return {
+ start: {
+ offset: startPos,
+ line: startPosDetails.line,
+ column: startPosDetails.column
+ },
+ end: {
+ offset: endPos,
+ line: endPosDetails.line,
+ column: endPosDetails.column
+ }
+ };
+ }
+
+ function peg$fail(expected) {
+ if (peg$currPos < peg$maxFailPos) { return; }
+
+ if (peg$currPos > peg$maxFailPos) {
+ peg$maxFailPos = peg$currPos;
+ peg$maxFailExpected = [];
+ }
+
+ peg$maxFailExpected.push(expected);
+ }
+
+ function peg$buildSimpleError(message, location) {
+ return new peg$SyntaxError(message, null, null, location);
+ }
+
+ function peg$buildStructuredError(expected, found, location) {
+ return new peg$SyntaxError(
+ peg$SyntaxError.buildMessage(expected, found),
+ expected,
+ found,
+ location
+ );
+ }
+
+ function peg$parseProject() {
+ var s0, s1, s2, s3, s4, s5, s6;
+
+ s0 = peg$currPos;
+ s1 = peg$parseSingleLineComment();
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseInlineComment();
+ if (s2 === peg$FAILED) {
+ s2 = null;
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseObject();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parseNewLine();
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parse_();
+ if (s6 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c0(s1, s4);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseObject() {
+ var s0, s1, s2, s3;
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 123) {
+ s1 = peg$c1;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c2); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseAssignmentList();
+ if (s2 === peg$FAILED) {
+ s2 = peg$parseEmptyBody();
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 125) {
+ s3 = peg$c3;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c4); }
+ }
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c5(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseEmptyBody() {
+ var s0, s1;
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c6();
+ }
+ s0 = s1;
+
+ return s0;
+ }
+
+ function peg$parseAssignmentList() {
+ var s0, s1, s2, s3, s4, s5;
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$currPos;
+ s4 = peg$parseAssignment();
+ if (s4 === peg$FAILED) {
+ s4 = peg$parseDelimitedSection();
+ }
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parse_();
+ if (s5 !== peg$FAILED) {
+ s4 = [s4, s5];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$currPos;
+ s4 = peg$parseAssignment();
+ if (s4 === peg$FAILED) {
+ s4 = peg$parseDelimitedSection();
+ }
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parse_();
+ if (s5 !== peg$FAILED) {
+ s4 = [s4, s5];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c7(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseAssignment() {
+ var s0;
+
+ s0 = peg$parseSimpleAssignment();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseCommentedAssignment();
+ }
+
+ return s0;
+ }
+
+ function peg$parseSimpleAssignment() {
+ var s0, s1, s2, s3, s4, s5, s6;
+
+ s0 = peg$currPos;
+ s1 = peg$parseIdentifier();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 61) {
+ s3 = peg$c8;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c9); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parseValue();
+ if (s5 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 59) {
+ s6 = peg$c10;
+ peg$currPos++;
+ } else {
+ s6 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c11); }
+ }
+ if (s6 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c12(s1, s5);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseCommentedAssignment() {
+ var s0, s1, s2, s3, s4, s5, s6;
+
+ s0 = peg$currPos;
+ s1 = peg$parseCommentedIdentifier();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 61) {
+ s3 = peg$c8;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c9); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parseValue();
+ if (s5 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 59) {
+ s6 = peg$c10;
+ peg$currPos++;
+ } else {
+ s6 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c11); }
+ }
+ if (s6 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c13(s1, s5);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parseIdentifier();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 61) {
+ s3 = peg$c8;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c9); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parseCommentedValue();
+ if (s5 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 59) {
+ s6 = peg$c10;
+ peg$currPos++;
+ } else {
+ s6 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c11); }
+ }
+ if (s6 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c14(s1, s5);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ }
+
+ return s0;
+ }
+
+ function peg$parseCommentedIdentifier() {
+ var s0, s1, s2, s3;
+
+ s0 = peg$currPos;
+ s1 = peg$parseIdentifier();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseInlineComment();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c15(s1, s3);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseCommentedValue() {
+ var s0, s1, s2, s3;
+
+ s0 = peg$currPos;
+ s1 = peg$parseValue();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseInlineComment();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c16(s1, s3);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseInlineComment() {
+ var s0, s1, s2, s3;
+
+ s0 = peg$currPos;
+ s1 = peg$parseInlineCommentOpen();
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c17.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c18); }
+ }
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c17.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c18); }
+ }
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseInlineCommentClose();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c19(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseInlineCommentOpen() {
+ var s0;
+
+ if (input.substr(peg$currPos, 2) === peg$c20) {
+ s0 = peg$c20;
+ peg$currPos += 2;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c21); }
+ }
+
+ return s0;
+ }
+
+ function peg$parseInlineCommentClose() {
+ var s0;
+
+ if (input.substr(peg$currPos, 2) === peg$c22) {
+ s0 = peg$c22;
+ peg$currPos += 2;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c23); }
+ }
+
+ return s0;
+ }
+
+ function peg$parseDelimitedSection() {
+ var s0, s1, s2, s3, s4, s5;
+
+ s0 = peg$currPos;
+ s1 = peg$parseDelimitedSectionBegin();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseAssignmentList();
+ if (s3 === peg$FAILED) {
+ s3 = peg$parseEmptyBody();
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parseDelimitedSectionEnd();
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c24(s1, s3);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseDelimitedSectionBegin() {
+ var s0, s1, s2, s3, s4;
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 9) === peg$c25) {
+ s1 = peg$c25;
+ peg$currPos += 9;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c26); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseIdentifier();
+ if (s2 !== peg$FAILED) {
+ if (input.substr(peg$currPos, 11) === peg$c27) {
+ s3 = peg$c27;
+ peg$currPos += 11;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c28); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseNewLine();
+ if (s4 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c29(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseDelimitedSectionEnd() {
+ var s0, s1, s2, s3, s4;
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 7) === peg$c30) {
+ s1 = peg$c30;
+ peg$currPos += 7;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c31); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseIdentifier();
+ if (s2 !== peg$FAILED) {
+ if (input.substr(peg$currPos, 11) === peg$c27) {
+ s3 = peg$c27;
+ peg$currPos += 11;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c28); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseNewLine();
+ if (s4 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c29(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseArray() {
+ var s0, s1, s2, s3;
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 40) {
+ s1 = peg$c32;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c33); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseArrayBody();
+ if (s2 === peg$FAILED) {
+ s2 = peg$parseEmptyArray();
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s3 = peg$c34;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c35); }
+ }
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c36(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseEmptyArray() {
+ var s0, s1;
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c37();
+ }
+ s0 = s1;
+
+ return s0;
+ }
+
+ function peg$parseArrayBody() {
+ var s0, s1, s2, s3, s4, s5;
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseArrayEntry();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseArrayBody();
+ if (s4 === peg$FAILED) {
+ s4 = null;
+ }
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parse_();
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c38(s2, s4);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseArrayEntry() {
+ var s0;
+
+ s0 = peg$parseSimpleArrayEntry();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseCommentedArrayEntry();
+ }
+
+ return s0;
+ }
+
+ function peg$parseSimpleArrayEntry() {
+ var s0, s1, s2;
+
+ s0 = peg$currPos;
+ s1 = peg$parseValue();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseEndArrayEntry();
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c39(s1);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseCommentedArrayEntry() {
+ var s0, s1, s2, s3, s4;
+
+ s0 = peg$currPos;
+ s1 = peg$parseValue();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseInlineComment();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseEndArrayEntry();
+ if (s4 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c40(s1, s3);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseEndArrayEntry() {
+ var s0, s1, s2, s3;
+
+ if (input.charCodeAt(peg$currPos) === 44) {
+ s0 = peg$c41;
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c42); }
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$currPos;
+ peg$silentFails++;
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s3 = peg$c34;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c35); }
+ }
+ peg$silentFails--;
+ if (s3 !== peg$FAILED) {
+ peg$currPos = s2;
+ s2 = void 0;
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = [s1, s2];
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ }
+
+ return s0;
+ }
+
+ function peg$parseIdentifier() {
+ var s0, s1, s2;
+
+ s0 = peg$currPos;
+ s1 = [];
+ if (peg$c43.test(input.charAt(peg$currPos))) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c44); }
+ }
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ if (peg$c43.test(input.charAt(peg$currPos))) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c44); }
+ }
+ }
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c45(s1);
+ }
+ s0 = s1;
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseQuotedString();
+ }
+
+ return s0;
+ }
+
+ function peg$parseValue() {
+ var s0;
+
+ s0 = peg$parseObject();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseArray();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseNumberValue();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseStringValue();
+ }
+ }
+ }
+
+ return s0;
+ }
+
+ function peg$parseNumberValue() {
+ var s0;
+
+ s0 = peg$parseDecimalValue();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseIntegerValue();
+ }
+
+ return s0;
+ }
+
+ function peg$parseDecimalValue() {
+ var s0, s1, s2, s3, s4;
+
+ s0 = peg$currPos;
+ s1 = peg$currPos;
+ s2 = peg$parseIntegerValue();
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s3 = peg$c46;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c47); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseIntegerValue();
+ if (s4 !== peg$FAILED) {
+ s2 = [s2, s3, s4];
+ s1 = s2;
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c48(s1);
+ }
+ s0 = s1;
+
+ return s0;
+ }
+
+ function peg$parseIntegerValue() {
+ var s0, s1, s2, s3, s4;
+
+ s0 = peg$currPos;
+ s1 = peg$currPos;
+ peg$silentFails++;
+ s2 = peg$parseAlpha();
+ peg$silentFails--;
+ if (s2 === peg$FAILED) {
+ s1 = void 0;
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$parseDigit();
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$parseDigit();
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$currPos;
+ peg$silentFails++;
+ s4 = peg$parseNonTerminator();
+ peg$silentFails--;
+ if (s4 === peg$FAILED) {
+ s3 = void 0;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c49(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseStringValue() {
+ var s0;
+
+ s0 = peg$parseQuotedString();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseLiteralString();
+ }
+
+ return s0;
+ }
+
+ function peg$parseQuotedString() {
+ var s0, s1, s2, s3;
+
+ s0 = peg$currPos;
+ s1 = peg$parseDoubleQuote();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseQuotedBody();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseDoubleQuote();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c50(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseQuotedBody() {
+ var s0, s1, s2;
+
+ s0 = peg$currPos;
+ s1 = [];
+ s2 = peg$parseNonQuote();
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ s2 = peg$parseNonQuote();
+ }
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c51(s1);
+ }
+ s0 = s1;
+
+ return s0;
+ }
+
+ function peg$parseNonQuote() {
+ var s0, s1, s2;
+
+ s0 = peg$parseEscapedQuote();
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$currPos;
+ peg$silentFails++;
+ s2 = peg$parseDoubleQuote();
+ peg$silentFails--;
+ if (s2 === peg$FAILED) {
+ s1 = void 0;
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c52); }
+ }
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c53(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ }
+
+ return s0;
+ }
+
+ function peg$parseEscapedQuote() {
+ var s0, s1, s2;
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s1 = peg$c54;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c55); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseDoubleQuote();
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c56();
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseLiteralString() {
+ var s0, s1, s2;
+
+ s0 = peg$currPos;
+ s1 = [];
+ s2 = peg$parseLiteralChar();
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ s2 = peg$parseLiteralChar();
+ }
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c57(s1);
+ }
+ s0 = s1;
+
+ return s0;
+ }
+
+ function peg$parseLiteralChar() {
+ var s0, s1, s2, s3;
+
+ s0 = peg$currPos;
+ s1 = peg$currPos;
+ peg$silentFails++;
+ s2 = peg$parseInlineCommentOpen();
+ peg$silentFails--;
+ if (s2 === peg$FAILED) {
+ s1 = void 0;
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$currPos;
+ peg$silentFails++;
+ s3 = peg$parseLineTerminator();
+ peg$silentFails--;
+ if (s3 === peg$FAILED) {
+ s2 = void 0;
+ } else {
+ peg$currPos = s2;
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseNonTerminator();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c53(s3);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseNonTerminator() {
+ var s0;
+
+ if (peg$c58.test(input.charAt(peg$currPos))) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c59); }
+ }
+
+ return s0;
+ }
+
+ function peg$parseSingleLineComment() {
+ var s0, s1, s2, s3, s4;
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 2) === peg$c60) {
+ s1 = peg$c60;
+ peg$currPos += 2;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c61); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseOneLineString();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseNewLine();
+ if (s4 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c62(s3);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseOneLineString() {
+ var s0, s1, s2;
+
+ s0 = peg$currPos;
+ s1 = [];
+ s2 = peg$parseNonLine();
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ s2 = peg$parseNonLine();
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c63(s1);
+ }
+ s0 = s1;
+
+ return s0;
+ }
+
+ function peg$parseDigit() {
+ var s0;
+
+ if (peg$c64.test(input.charAt(peg$currPos))) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c65); }
+ }
+
+ return s0;
+ }
+
+ function peg$parseAlpha() {
+ var s0;
+
+ if (peg$c66.test(input.charAt(peg$currPos))) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c67); }
+ }
+
+ return s0;
+ }
+
+ function peg$parseDoubleQuote() {
+ var s0;
+
+ if (input.charCodeAt(peg$currPos) === 34) {
+ s0 = peg$c68;
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c69); }
+ }
+
+ return s0;
+ }
+
+ function peg$parse_() {
+ var s0, s1;
+
+ peg$silentFails++;
+ s0 = [];
+ s1 = peg$parsewhitespace();
+ while (s1 !== peg$FAILED) {
+ s0.push(s1);
+ s1 = peg$parsewhitespace();
+ }
+ peg$silentFails--;
+ if (s0 === peg$FAILED) {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c70); }
+ }
+
+ return s0;
+ }
+
+ function peg$parsewhitespace() {
+ var s0;
+
+ s0 = peg$parseNewLine();
+ if (s0 === peg$FAILED) {
+ if (peg$c71.test(input.charAt(peg$currPos))) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c72); }
+ }
+ }
+
+ return s0;
+ }
+
+ function peg$parseNonLine() {
+ var s0, s1, s2;
+
+ s0 = peg$currPos;
+ s1 = peg$currPos;
+ peg$silentFails++;
+ s2 = peg$parseNewLine();
+ peg$silentFails--;
+ if (s2 === peg$FAILED) {
+ s1 = void 0;
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseChar();
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c53(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ return s0;
+ }
+
+ function peg$parseLineTerminator() {
+ var s0;
+
+ s0 = peg$parseNewLine();
+ if (s0 === peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 59) {
+ s0 = peg$c10;
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c11); }
+ }
+ }
+
+ return s0;
+ }
+
+ function peg$parseNewLine() {
+ var s0;
+
+ if (peg$c73.test(input.charAt(peg$currPos))) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c74); }
+ }
+
+ return s0;
+ }
+
+ function peg$parseChar() {
+ var s0;
+
+ if (input.length > peg$currPos) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c52); }
+ }
+
+ return s0;
+ }
+
+
+ function merge_obj(obj, secondObj) {
+ if (!obj)
+ return secondObj;
+
+ for(var i in secondObj)
+ obj[i] = merge_obj(obj[i], secondObj[i]);
+
+ return obj;
+ }
+
+
+ peg$result = peg$startRuleFunction();
+
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
+ return peg$result;
+ } else {
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
+ peg$fail(peg$endExpectation());
+ }
+
+ throw peg$buildStructuredError(
+ peg$maxFailExpected,
+ peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
+ peg$maxFailPos < input.length
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
+ );
+ }
+}
+
+module.exports = {
+ SyntaxError: peg$SyntaxError,
+ parse: peg$parse
+};
diff --git a/cordova/node_modules/xcode/lib/parser/pbxproj.pegjs b/cordova/node_modules/xcode/lib/parser/pbxproj.pegjs
new file mode 100755
index 0000000..c612689
--- /dev/null
+++ b/cordova/node_modules/xcode/lib/parser/pbxproj.pegjs
@@ -0,0 +1,263 @@
+{
+ function merge_obj(obj, secondObj) {
+ if (!obj)
+ return secondObj;
+
+ for(var i in secondObj)
+ obj[i] = merge_obj(obj[i], secondObj[i]);
+
+ return obj;
+ }
+}
+
+/*
+ * Project: point of entry from pbxproj file
+ */
+Project
+ = headComment:SingleLineComment? InlineComment? _ obj:Object NewLine _
+ {
+ var proj = Object.create(null)
+ proj.project = obj
+
+ if (headComment) {
+ proj.headComment = headComment
+ }
+
+ return proj;
+ }
+
+/*
+ * Object: basic hash data structure with Assignments
+ */
+Object
+ = "{" obj:(AssignmentList / EmptyBody) "}"
+ { return obj }
+
+EmptyBody
+ = _
+ { return Object.create(null) }
+
+AssignmentList
+ = _ list:((a:Assignment / d:DelimitedSection) _)+
+ {
+ var returnObject = list[0][0];
+ for(var i = 1; i < list.length; i++){
+ var another = list[i][0];
+ returnObject = merge_obj(returnObject, another);
+ }
+ return returnObject;
+ }
+
+/*
+ * Assignments
+ * can be simple "key = value"
+ * or commented "key /* real key * / = value"
+ */
+Assignment
+ = SimpleAssignment / CommentedAssignment
+
+SimpleAssignment
+ = id:Identifier _ "=" _ val:Value ";"
+ {
+ var result = Object.create(null);
+ result[id] = val
+ return result
+ }
+
+CommentedAssignment
+ = commentedId:CommentedIdentifier _ "=" _ val:Value ";"
+ {
+ var result = Object.create(null),
+ commentKey = commentedId.id + '_comment';
+
+ result[commentedId.id] = val;
+ result[commentKey] = commentedId[commentKey];
+ return result;
+
+ }
+ /
+ id:Identifier _ "=" _ commentedVal:CommentedValue ";"
+ {
+ var result = Object.create(null);
+ result[id] = commentedVal.value;
+ result[id + "_comment"] = commentedVal.comment;
+ return result;
+ }
+
+CommentedIdentifier
+ = id:Identifier _ comment:InlineComment
+ {
+ var result = Object.create(null);
+ result.id = id;
+ result[id + "_comment"] = comment.trim();
+ return result
+ }
+
+CommentedValue
+ = literal:Value _ comment:InlineComment
+ {
+ var result = Object.create(null)
+ result.comment = comment.trim();
+ result.value = literal.trim();
+ return result;
+ }
+
+InlineComment
+ = InlineCommentOpen body:[^*]+ InlineCommentClose
+ { return body.join('') }
+
+InlineCommentOpen
+ = "/*"
+
+InlineCommentClose
+ = "*/"
+
+/*
+ * DelimitedSection - ad hoc project structure pbxproj files use
+ */
+DelimitedSection
+ = begin:DelimitedSectionBegin _ fields:(AssignmentList / EmptyBody) _ DelimitedSectionEnd
+ {
+ var section = Object.create(null);
+ section[begin.name] = fields
+
+ return section
+ }
+
+DelimitedSectionBegin
+ = "/* Begin " sectionName:Identifier " section */" NewLine
+ { return { name: sectionName } }
+
+DelimitedSectionEnd
+ = "/* End " sectionName:Identifier " section */" NewLine
+ { return { name: sectionName } }
+
+/*
+ * Arrays: lists of values, possible wth comments
+ */
+Array
+ = "(" arr:(ArrayBody / EmptyArray ) ")" { return arr }
+
+EmptyArray
+ = _ { return [] }
+
+ArrayBody
+ = _ head:ArrayEntry _ tail:ArrayBody? _
+ {
+ if (tail) {
+ tail.unshift(head);
+ return tail;
+ } else {
+ return [head];
+ }
+ }
+
+ArrayEntry
+ = SimpleArrayEntry / CommentedArrayEntry
+
+SimpleArrayEntry
+ = val:Value EndArrayEntry { return val }
+
+CommentedArrayEntry
+ = val:Value _ comment:InlineComment EndArrayEntry
+ {
+ var result = Object.create(null);
+ result.value = val.trim();
+ result.comment = comment.trim();
+ return result;
+ }
+
+EndArrayEntry
+ = "," / _ &")"
+
+/*
+ * Identifiers and Values
+ */
+Identifier
+ = id:[A-Za-z0-9_.]+ { return id.join('') }
+ / QuotedString
+
+Value
+ = Object / Array / NumberValue / StringValue
+
+NumberValue
+ = DecimalValue / IntegerValue
+
+DecimalValue
+ = decimal:(IntegerValue "." IntegerValue)
+ {
+ // store decimals as strings
+ // as JS doesn't differentiate bw strings and numbers
+ return decimal.join('')
+ }
+
+IntegerValue
+ = !Alpha number:Digit+ !NonTerminator
+ { return parseInt(number.join(''), 10) }
+
+StringValue
+ = QuotedString / LiteralString
+
+QuotedString
+ = DoubleQuote str:QuotedBody DoubleQuote { return '"' + str + '"' }
+
+QuotedBody
+ = str:NonQuote+ { return str.join('') }
+
+NonQuote
+ = EscapedQuote / !DoubleQuote char:. { return char }
+
+EscapedQuote
+ = "\\" DoubleQuote { return '\\"' }
+
+LiteralString
+ = literal:LiteralChar+ { return literal.join('') }
+
+LiteralChar
+ = !InlineCommentOpen !LineTerminator char:NonTerminator
+ { return char }
+
+NonTerminator
+ = [^;,\n]
+
+/*
+ * SingleLineComment - used for the encoding comment
+ */
+SingleLineComment
+ = "//" _ contents:OneLineString NewLine
+ { return contents }
+
+OneLineString
+ = contents:NonLine*
+ { return contents.join('') }
+
+/*
+ * Simple character checking rules
+ */
+Digit
+ = [0-9]
+
+Alpha
+ = [A-Za-z]
+
+DoubleQuote
+ = '"'
+
+_ "whitespace"
+ = whitespace*
+
+whitespace
+ = NewLine / [\t ]
+
+NonLine
+ = !NewLine char:Char
+ { return char }
+
+LineTerminator
+ = NewLine / ";"
+
+NewLine
+ = [\n\r]
+
+Char
+ = .
diff --git a/cordova/node_modules/xcode/lib/pbxFile.js b/cordova/node_modules/xcode/lib/pbxFile.js
new file mode 100755
index 0000000..768122a
--- /dev/null
+++ b/cordova/node_modules/xcode/lib/pbxFile.js
@@ -0,0 +1,215 @@
+var path = require('path'),
+ util = require('util');
+
+var DEFAULT_SOURCETREE = '"<group>"',
+ DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR',
+ DEFAULT_FILEENCODING = 4,
+ DEFAULT_GROUP = 'Resources',
+ DEFAULT_FILETYPE = 'unknown';
+
+var FILETYPE_BY_EXTENSION = {
+ a: 'archive.ar',
+ app: 'wrapper.application',
+ appex: 'wrapper.app-extension',
+ bundle: 'wrapper.plug-in',
+ dylib: 'compiled.mach-o.dylib',
+ framework: 'wrapper.framework',
+ h: 'sourcecode.c.h',
+ m: 'sourcecode.c.objc',
+ markdown: 'text',
+ mdimporter: 'wrapper.cfbundle',
+ octest: 'wrapper.cfbundle',
+ pch: 'sourcecode.c.h',
+ plist: 'text.plist.xml',
+ sh: 'text.script.sh',
+ swift: 'sourcecode.swift',
+ tbd: 'sourcecode.text-based-dylib-definition',
+ xcassets: 'folder.assetcatalog',
+ xcconfig: 'text.xcconfig',
+ xcdatamodel: 'wrapper.xcdatamodel',
+ xcodeproj: 'wrapper.pb-project',
+ xctest: 'wrapper.cfbundle',
+ xib: 'file.xib',
+ strings: 'text.plist.strings'
+ },
+ GROUP_BY_FILETYPE = {
+ 'archive.ar': 'Frameworks',
+ 'compiled.mach-o.dylib': 'Frameworks',
+ 'sourcecode.text-based-dylib-definition': 'Frameworks',
+ 'wrapper.framework': 'Frameworks',
+ 'embedded.framework': 'Embed Frameworks',
+ 'sourcecode.c.h': 'Resources',
+ 'sourcecode.c.objc': 'Sources',
+ 'sourcecode.swift': 'Sources'
+ },
+ PATH_BY_FILETYPE = {
+ 'compiled.mach-o.dylib': 'usr/lib/',
+ 'sourcecode.text-based-dylib-definition': 'usr/lib/',
+ 'wrapper.framework': 'System/Library/Frameworks/'
+ },
+ SOURCETREE_BY_FILETYPE = {
+ 'compiled.mach-o.dylib': 'SDKROOT',
+ 'sourcecode.text-based-dylib-definition': 'SDKROOT',
+ 'wrapper.framework': 'SDKROOT'
+ },
+ ENCODING_BY_FILETYPE = {
+ 'sourcecode.c.h': 4,
+ 'sourcecode.c.h': 4,
+ 'sourcecode.c.objc': 4,
+ 'sourcecode.swift': 4,
+ 'text': 4,
+ 'text.plist.xml': 4,
+ 'text.script.sh': 4,
+ 'text.xcconfig': 4,
+ 'text.plist.strings': 4
+ };
+
+
+function unquoted(text){
+ return text.replace (/(^")|("$)/g, '')
+}
+
+function detectType(filePath) {
+ var extension = path.extname(filePath).substring(1),
+ filetype = FILETYPE_BY_EXTENSION[unquoted(extension)];
+
+ if (!filetype) {
+ return DEFAULT_FILETYPE;
+ }
+
+ return filetype;
+}
+
+function defaultExtension(fileRef) {
+ var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType;
+
+ for(var extension in FILETYPE_BY_EXTENSION) {
+ if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) {
+ if(FILETYPE_BY_EXTENSION[unquoted(extension)] === filetype )
+ return extension;
+ }
+ }
+}
+
+function defaultEncoding(fileRef) {
+ var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
+ encoding = ENCODING_BY_FILETYPE[unquoted(filetype)];
+
+ if (encoding) {
+ return encoding;
+ }
+}
+
+function detectGroup(fileRef, opt) {
+ var extension = path.extname(fileRef.basename).substring(1),
+ filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
+ groupName = GROUP_BY_FILETYPE[unquoted(filetype)];
+
+ if (extension === 'xcdatamodeld') {
+ return 'Sources';
+ }
+
+ if (opt.customFramework && opt.embed) {
+ return GROUP_BY_FILETYPE['embedded.framework'];
+ }
+
+ if (!groupName) {
+ return DEFAULT_GROUP;
+ }
+
+ return groupName;
+}
+
+function detectSourcetree(fileRef) {
+
+ var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
+ sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)];
+
+ if (fileRef.explicitFileType) {
+ return DEFAULT_PRODUCT_SOURCETREE;
+ }
+
+ if (fileRef.customFramework) {
+ return DEFAULT_SOURCETREE;
+ }
+
+ if (!sourcetree) {
+ return DEFAULT_SOURCETREE;
+ }
+
+ return sourcetree;
+}
+
+function defaultPath(fileRef, filePath) {
+ var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
+ defaultPath = PATH_BY_FILETYPE[unquoted(filetype)];
+
+ if (fileRef.customFramework) {
+ return filePath;
+ }
+
+ if (defaultPath) {
+ return path.join(defaultPath, path.basename(filePath));
+ }
+
+ return filePath;
+}
+
+function defaultGroup(fileRef) {
+ var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType];
+
+ if (!groupName) {
+ return DEFAULT_GROUP;
+ }
+
+ return defaultGroup;
+}
+
+function pbxFile(filepath, opt) {
+ var opt = opt || {};
+
+ this.basename = path.basename(filepath);
+ this.lastKnownFileType = opt.lastKnownFileType || detectType(filepath);
+ this.group = detectGroup(this, opt);
+
+ // for custom frameworks
+ if (opt.customFramework == true) {
+ this.customFramework = true;
+ this.dirname = path.dirname(filepath).replace(/\\/g, '/');
+ }
+
+ this.path = defaultPath(this, filepath).replace(/\\/g, '/');
+ this.fileEncoding = this.defaultEncoding = opt.defaultEncoding || defaultEncoding(this);
+
+ // When referencing products / build output files
+ if (opt.explicitFileType) {
+ this.explicitFileType = opt.explicitFileType;
+ this.basename = this.basename + '.' + defaultExtension(this);
+ delete this.path;
+ delete this.lastKnownFileType;
+ delete this.group;
+ delete this.defaultEncoding;
+ }
+
+ this.sourceTree = opt.sourceTree || detectSourcetree(this);
+ this.includeInIndex = 0;
+
+ if (opt.weak && opt.weak === true)
+ this.settings = { ATTRIBUTES: ['Weak'] };
+
+ if (opt.compilerFlags) {
+ if (!this.settings)
+ this.settings = {};
+ this.settings.COMPILER_FLAGS = util.format('"%s"', opt.compilerFlags);
+ }
+
+ if (opt.embed && opt.sign) {
+ if (!this.settings)
+ this.settings = {};
+ if (!this.settings.ATTRIBUTES)
+ this.settings.ATTRIBUTES = [];
+ this.settings.ATTRIBUTES.push('CodeSignOnCopy');
+ }
+}
+
+module.exports = pbxFile;
diff --git a/cordova/node_modules/xcode/lib/pbxProject.js b/cordova/node_modules/xcode/lib/pbxProject.js
new file mode 100755
index 0000000..18033bb
--- /dev/null
+++ b/cordova/node_modules/xcode/lib/pbxProject.js
@@ -0,0 +1,2059 @@
+var util = require('util'),
+ f = util.format,
+ EventEmitter = require('events').EventEmitter,
+ path = require('path'),
+ uuid = require('uuid'),
+ fork = require('child_process').fork,
+ pbxWriter = require('./pbxWriter'),
+ pbxFile = require('./pbxFile'),
+ fs = require('fs'),
+ parser = require('./parser/pbxproj'),
+ plist = require('simple-plist'),
+ COMMENT_KEY = /_comment$/
+
+function pbxProject(filename) {
+ if (!(this instanceof pbxProject))
+ return new pbxProject(filename);
+
+ this.filepath = path.resolve(filename)
+}
+
+util.inherits(pbxProject, EventEmitter)
+
+pbxProject.prototype.parse = function(cb) {
+ var worker = fork(__dirname + '/parseJob.js', [this.filepath])
+
+ worker.on('message', function(msg) {
+ if (msg.name == 'SyntaxError' || msg.code) {
+ this.emit('error', msg);
+ } else {
+ this.hash = msg;
+ this.emit('end', null, msg)
+ }
+ }.bind(this));
+
+ if (cb) {
+ this.on('error', cb);
+ this.on('end', cb);
+ }
+
+ return this;
+}
+
+pbxProject.prototype.parseSync = function() {
+ var file_contents = fs.readFileSync(this.filepath, 'utf-8');
+
+ this.hash = parser.parse(file_contents);
+ return this;
+}
+
+pbxProject.prototype.writeSync = function() {
+ this.writer = new pbxWriter(this.hash);
+ return this.writer.writeSync();
+}
+
+pbxProject.prototype.allUuids = function() {
+ var sections = this.hash.project.objects,
+ uuids = [],
+ section;
+
+ for (key in sections) {
+ section = sections[key]
+ uuids = uuids.concat(Object.keys(section))
+ }
+
+ uuids = uuids.filter(function(str) {
+ return !COMMENT_KEY.test(str) && str.length == 24;
+ });
+
+ return uuids;
+}
+
+pbxProject.prototype.generateUuid = function() {
+ var id = uuid.v4()
+ .replace(/-/g, '')
+ .substr(0, 24)
+ .toUpperCase()
+
+ if (this.allUuids().indexOf(id) >= 0) {
+ return this.generateUuid();
+ } else {
+ return id;
+ }
+}
+
+pbxProject.prototype.addPluginFile = function(path, opt) {
+ var file = new pbxFile(path, opt);
+
+ file.plugin = true; // durr
+ correctForPluginsPath(file, this);
+
+ // null is better for early errors
+ if (this.hasFile(file.path)) return null;
+
+ file.fileRef = this.generateUuid();
+
+ this.addToPbxFileReferenceSection(file); // PBXFileReference
+ this.addToPluginsPbxGroup(file); // PBXGroup
+
+ return file;
+}
+
+pbxProject.prototype.removePluginFile = function(path, opt) {
+ var file = new pbxFile(path, opt);
+ correctForPluginsPath(file, this);
+
+ this.removeFromPbxFileReferenceSection(file); // PBXFileReference
+ this.removeFromPluginsPbxGroup(file); // PBXGroup
+
+ return file;
+}
+
+pbxProject.prototype.addProductFile = function(targetPath, opt) {
+ var file = new pbxFile(targetPath, opt);
+
+ file.includeInIndex = 0;
+ file.fileRef = this.generateUuid();
+ file.target = opt ? opt.target : undefined;
+ file.group = opt ? opt.group : undefined;
+ file.uuid = this.generateUuid();
+ file.path = file.basename;
+
+ this.addToPbxFileReferenceSection(file);
+ this.addToProductsPbxGroup(file); // PBXGroup
+
+ return file;
+}
+
+pbxProject.prototype.removeProductFile = function(path, opt) {
+ var file = new pbxFile(path, opt);
+
+ this.removeFromProductsPbxGroup(file); // PBXGroup
+
+ return file;
+}
+
+/**
+ *
+ * @param path {String}
+ * @param opt {Object} see pbxFile for avail options
+ * @param group {String} group key
+ * @returns {Object} file; see pbxFile
+ */
+pbxProject.prototype.addSourceFile = function (path, opt, group) {
+ var file;
+ if (group) {
+ file = this.addFile(path, group, opt);
+ }
+ else {
+ file = this.addPluginFile(path, opt);
+ }
+
+ if (!file) return false;
+
+ file.target = opt ? opt.target : undefined;
+ file.uuid = this.generateUuid();
+
+ this.addToPbxBuildFileSection(file); // PBXBuildFile
+ this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase
+
+ return file;
+}
+
+/**
+ *
+ * @param path {String}
+ * @param opt {Object} see pbxFile for avail options
+ * @param group {String} group key
+ * @returns {Object} file; see pbxFile
+ */
+pbxProject.prototype.removeSourceFile = function (path, opt, group) {
+ var file;
+ if (group) {
+ file = this.removeFile(path, group, opt);
+ }
+ else {
+ file = this.removePluginFile(path, opt);
+ }
+ file.target = opt ? opt.target : undefined;
+ this.removeFromPbxBuildFileSection(file); // PBXBuildFile
+ this.removeFromPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase
+
+ return file;
+}
+
+/**
+ *
+ * @param path {String}
+ * @param opt {Object} see pbxFile for avail options
+ * @param group {String} group key
+ * @returns {Object} file; see pbxFile
+ */
+pbxProject.prototype.addHeaderFile = function (path, opt, group) {
+ if (group) {
+ return this.addFile(path, group, opt);
+ }
+ else {
+ return this.addPluginFile(path, opt);
+ }
+}
+
+/**
+ *
+ * @param path {String}
+ * @param opt {Object} see pbxFile for avail options
+ * @param group {String} group key
+ * @returns {Object} file; see pbxFile
+ */
+pbxProject.prototype.removeHeaderFile = function (path, opt, group) {
+ if (group) {
+ return this.removeFile(path, group, opt);
+ }
+ else {
+ return this.removePluginFile(path, opt);
+ }
+}
+
+/**
+ *
+ * @param path {String}
+ * @param opt {Object} see pbxFile for avail options
+ * @param group {String} group key
+ * @returns {Object} file; see pbxFile
+ */
+pbxProject.prototype.addResourceFile = function(path, opt, group) {
+ opt = opt || {};
+
+ var file;
+
+ if (opt.plugin) {
+ file = this.addPluginFile(path, opt);
+ if (!file) return false;
+ } else {
+ file = new pbxFile(path, opt);
+ if (this.hasFile(file.path)) return false;
+ }
+
+ file.uuid = this.generateUuid();
+ file.target = opt ? opt.target : undefined;
+
+ if (!opt.plugin) {
+ correctForResourcesPath(file, this);
+ file.fileRef = this.generateUuid();
+ }
+
+ if (!opt.variantGroup) {
+ this.addToPbxBuildFileSection(file); // PBXBuildFile
+ this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
+ }
+
+ if (!opt.plugin) {
+ this.addToPbxFileReferenceSection(file); // PBXFileReference
+ if (group) {
+ if (this.getPBXGroupByKey(group)) {
+ this.addToPbxGroup(file, group); //Group other than Resources (i.e. 'splash')
+ }
+ else if (this.getPBXVariantGroupByKey(group)) {
+ this.addToPbxVariantGroup(file, group); // PBXVariantGroup
+ }
+ }
+ else {
+ this.addToResourcesPbxGroup(file); // PBXGroup
+ }
+
+ }
+
+ return file;
+}
+
+/**
+ *
+ * @param path {String}
+ * @param opt {Object} see pbxFile for avail options
+ * @param group {String} group key
+ * @returns {Object} file; see pbxFile
+ */
+pbxProject.prototype.removeResourceFile = function(path, opt, group) {
+ var file = new pbxFile(path, opt);
+ file.target = opt ? opt.target : undefined;
+
+ correctForResourcesPath(file, this);
+
+ this.removeFromPbxBuildFileSection(file); // PBXBuildFile
+ this.removeFromPbxFileReferenceSection(file); // PBXFileReference
+ if (group) {
+ if (this.getPBXGroupByKey(group)) {
+ this.removeFromPbxGroup(file, group); //Group other than Resources (i.e. 'splash')
+ }
+ else if (this.getPBXVariantGroupByKey(group)) {
+ this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup
+ }
+ }
+ else {
+ this.removeFromResourcesPbxGroup(file); // PBXGroup
+ }
+ this.removeFromPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
+
+ return file;
+}
+
+pbxProject.prototype.addFramework = function(fpath, opt) {
+ var customFramework = opt && opt.customFramework == true;
+ var link = !opt || (opt.link == undefined || opt.link); //defaults to true if not specified
+ var embed = opt && opt.embed; //defaults to false if not specified
+
+ if (opt) {
+ delete opt.embed;
+ }
+
+ var file = new pbxFile(fpath, opt);
+
+ file.uuid = this.generateUuid();
+ file.fileRef = this.generateUuid();
+ file.target = opt ? opt.target : undefined;
+
+ if (this.hasFile(file.path)) return false;
+
+ this.addToPbxBuildFileSection(file); // PBXBuildFile
+ this.addToPbxFileReferenceSection(file); // PBXFileReference
+ this.addToFrameworksPbxGroup(file); // PBXGroup
+
+ if (link) {
+ this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase
+ }
+
+ if (customFramework) {
+ this.addToFrameworkSearchPaths(file);
+
+ if (embed) {
+ opt.embed = embed;
+ var embeddedFile = new pbxFile(fpath, opt);
+
+ embeddedFile.uuid = this.generateUuid();
+ embeddedFile.fileRef = file.fileRef;
+
+ //keeping a separate PBXBuildFile entry for Embed Frameworks
+ this.addToPbxBuildFileSection(embeddedFile); // PBXBuildFile
+
+ this.addToPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase
+
+ return embeddedFile;
+ }
+ }
+
+ return file;
+}
+
+pbxProject.prototype.removeFramework = function(fpath, opt) {
+ var embed = opt && opt.embed;
+
+ if (opt) {
+ delete opt.embed;
+ }
+
+ var file = new pbxFile(fpath, opt);
+ file.target = opt ? opt.target : undefined;
+
+ this.removeFromPbxBuildFileSection(file); // PBXBuildFile
+ this.removeFromPbxFileReferenceSection(file); // PBXFileReference
+ this.removeFromFrameworksPbxGroup(file); // PBXGroup
+ this.removeFromPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase
+
+ if (opt && opt.customFramework) {
+ this.removeFromFrameworkSearchPaths(file);
+ }
+
+ opt = opt || {};
+ opt.embed = true;
+ var embeddedFile = new pbxFile(fpath, opt);
+
+ embeddedFile.fileRef = file.fileRef;
+
+ this.removeFromPbxBuildFileSection(embeddedFile); // PBXBuildFile
+ this.removeFromPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase
+
+ return file;
+}
+
+
+pbxProject.prototype.addCopyfile = function(fpath, opt) {
+ var file = new pbxFile(fpath, opt);
+
+ // catch duplicates
+ if (this.hasFile(file.path)) {
+ file = this.hasFile(file.path);
+ }
+
+ file.fileRef = file.uuid = this.generateUuid();
+ file.target = opt ? opt.target : undefined;
+
+ this.addToPbxBuildFileSection(file); // PBXBuildFile
+ this.addToPbxFileReferenceSection(file); // PBXFileReference
+ this.addToPbxCopyfilesBuildPhase(file); // PBXCopyFilesBuildPhase
+
+ return file;
+}
+
+pbxProject.prototype.pbxCopyfilesBuildPhaseObj = function(target) {
+ return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', target);
+}
+
+pbxProject.prototype.addToPbxCopyfilesBuildPhase = function(file) {
+ var sources = this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', file.target);
+ sources.files.push(pbxBuildPhaseObj(file));
+}
+
+pbxProject.prototype.removeCopyfile = function(fpath, opt) {
+ var file = new pbxFile(fpath, opt);
+ file.target = opt ? opt.target : undefined;
+
+ this.removeFromPbxBuildFileSection(file); // PBXBuildFile
+ this.removeFromPbxFileReferenceSection(file); // PBXFileReference
+ this.removeFromPbxCopyfilesBuildPhase(file); // PBXFrameworksBuildPhase
+
+ return file;
+}
+
+pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function(file) {
+ var sources = this.pbxCopyfilesBuildPhaseObj(file.target);
+ for (i in sources.files) {
+ if (sources.files[i].comment == longComment(file)) {
+ sources.files.splice(i, 1);
+ break;
+ }
+ }
+}
+
+pbxProject.prototype.addStaticLibrary = function(path, opt) {
+ opt = opt || {};
+
+ var file;
+
+ if (opt.plugin) {
+ file = this.addPluginFile(path, opt);
+ if (!file) return false;
+ } else {
+ file = new pbxFile(path, opt);
+ if (this.hasFile(file.path)) return false;
+ }
+
+ file.uuid = this.generateUuid();
+ file.target = opt ? opt.target : undefined;
+
+ if (!opt.plugin) {
+ file.fileRef = this.generateUuid();
+ this.addToPbxFileReferenceSection(file); // PBXFileReference
+ }
+
+ this.addToPbxBuildFileSection(file); // PBXBuildFile
+ this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase
+ this.addToLibrarySearchPaths(file); // make sure it gets built!
+
+ return file;
+}
+
+// helper addition functions
+pbxProject.prototype.addToPbxBuildFileSection = function(file) {
+ var commentKey = f("%s_comment", file.uuid);
+
+ this.pbxBuildFileSection()[file.uuid] = pbxBuildFileObj(file);
+ this.pbxBuildFileSection()[commentKey] = pbxBuildFileComment(file);
+}
+
+pbxProject.prototype.removeFromPbxBuildFileSection = function(file) {
+ var uuid;
+
+ for (uuid in this.pbxBuildFileSection()) {
+ if (this.pbxBuildFileSection()[uuid].fileRef_comment == file.basename) {
+ file.uuid = uuid;
+ delete this.pbxBuildFileSection()[uuid];
+ }
+ }
+ var commentKey = f("%s_comment", file.uuid);
+ delete this.pbxBuildFileSection()[commentKey];
+}
+
+pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTree) {
+ var groups = this.hash.project.objects['PBXGroup'],
+ pbxGroupUuid = this.generateUuid(),
+ commentKey = f("%s_comment", pbxGroupUuid),
+ pbxGroup = {
+ isa: 'PBXGroup',
+ children: [],
+ name: name,
+ path: path,
+ sourceTree: sourceTree ? sourceTree : '"<group>"'
+ },
+ fileReferenceSection = this.pbxFileReferenceSection(),
+ filePathToReference = {};
+
+ for (var key in fileReferenceSection) {
+ // only look for comments
+ if (!COMMENT_KEY.test(key)) continue;
+
+ var fileReferenceKey = key.split(COMMENT_KEY)[0],
+ fileReference = fileReferenceSection[fileReferenceKey];
+
+ filePathToReference[fileReference.path] = { fileRef: fileReferenceKey, basename: fileReferenceSection[key] };
+ }
+
+ for (var index = 0; index < filePathsArray.length; index++) {
+ var filePath = filePathsArray[index],
+ filePathQuoted = "\"" + filePath + "\"";
+ if (filePathToReference[filePath]) {
+ pbxGroup.children.push(pbxGroupChild(filePathToReference[filePath]));
+ continue;
+ } else if (filePathToReference[filePathQuoted]) {
+ pbxGroup.children.push(pbxGroupChild(filePathToReference[filePathQuoted]));
+ continue;
+ }
+
+ var file = new pbxFile(filePath);
+ file.uuid = this.generateUuid();
+ file.fileRef = this.generateUuid();
+ this.addToPbxFileReferenceSection(file); // PBXFileReference
+ this.addToPbxBuildFileSection(file); // PBXBuildFile
+ pbxGroup.children.push(pbxGroupChild(file));
+ }
+
+ if (groups) {
+ groups[pbxGroupUuid] = pbxGroup;
+ groups[commentKey] = name;
+ }
+
+ return { uuid: pbxGroupUuid, pbxGroup: pbxGroup };
+}
+
+pbxProject.prototype.removePbxGroup = function (groupName) {
+ var section = this.hash.project.objects['PBXGroup'],
+ key, itemKey;
+
+ for (key in section) {
+ // only look for comments
+ if (!COMMENT_KEY.test(key)) continue;
+
+ if (section[key] == groupName) {
+ itemKey = key.split(COMMENT_KEY)[0];
+ delete section[itemKey];
+ }
+ }
+}
+
+pbxProject.prototype.addToPbxProjectSection = function(target) {
+
+ var newTarget = {
+ value: target.uuid,
+ comment: pbxNativeTargetComment(target.pbxNativeTarget)
+ };
+
+ this.pbxProjectSection()[this.getFirstProject()['uuid']]['targets'].push(newTarget);
+}
+
+pbxProject.prototype.addToPbxNativeTargetSection = function(target) {
+ var commentKey = f("%s_comment", target.uuid);
+
+ this.pbxNativeTargetSection()[target.uuid] = target.pbxNativeTarget;
+ this.pbxNativeTargetSection()[commentKey] = target.pbxNativeTarget.name;
+}
+
+pbxProject.prototype.addToPbxFileReferenceSection = function(file) {
+ var commentKey = f("%s_comment", file.fileRef);
+
+ this.pbxFileReferenceSection()[file.fileRef] = pbxFileReferenceObj(file);
+ this.pbxFileReferenceSection()[commentKey] = pbxFileReferenceComment(file);
+}
+
+pbxProject.prototype.removeFromPbxFileReferenceSection = function(file) {
+
+ var i;
+ var refObj = pbxFileReferenceObj(file);
+ for (i in this.pbxFileReferenceSection()) {
+ if (this.pbxFileReferenceSection()[i].name == refObj.name ||
+ ('"' + this.pbxFileReferenceSection()[i].name + '"') == refObj.name ||
+ this.pbxFileReferenceSection()[i].path == refObj.path ||
+ ('"' + this.pbxFileReferenceSection()[i].path + '"') == refObj.path) {
+ file.fileRef = file.uuid = i;
+ delete this.pbxFileReferenceSection()[i];
+ break;
+ }
+ }
+ var commentKey = f("%s_comment", file.fileRef);
+ if (this.pbxFileReferenceSection()[commentKey] != undefined) {
+ delete this.pbxFileReferenceSection()[commentKey];
+ }
+
+ return file;
+}
+
+pbxProject.prototype.addToXcVersionGroupSection = function(file) {
+ if (!file.models || !file.currentModel) {
+ throw new Error("Cannot create a XCVersionGroup section from not a data model document file");
+ }
+
+ var commentKey = f("%s_comment", file.fileRef);
+
+ if (!this.xcVersionGroupSection()[file.fileRef]) {
+ this.xcVersionGroupSection()[file.fileRef] = {
+ isa: 'XCVersionGroup',
+ children: file.models.map(function (el) { return el.fileRef; }),
+ currentVersion: file.currentModel.fileRef,
+ name: path.basename(file.path),
+ path: file.path,
+ sourceTree: '"<group>"',
+ versionGroupType: 'wrapper.xcdatamodel'
+ };
+ this.xcVersionGroupSection()[commentKey] = path.basename(file.path);
+ }
+}
+
+pbxProject.prototype.addToPluginsPbxGroup = function(file) {
+ var pluginsGroup = this.pbxGroupByName('Plugins');
+ pluginsGroup.children.push(pbxGroupChild(file));
+}
+
+pbxProject.prototype.removeFromPluginsPbxGroup = function(file) {
+ var pluginsGroupChildren = this.pbxGroupByName('Plugins').children, i;
+ for (i in pluginsGroupChildren) {
+ if (pbxGroupChild(file).value == pluginsGroupChildren[i].value &&
+ pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) {
+ pluginsGroupChildren.splice(i, 1);
+ break;
+ }
+ }
+}
+
+pbxProject.prototype.addToResourcesPbxGroup = function(file) {
+ var pluginsGroup = this.pbxGroupByName('Resources');
+ pluginsGroup.children.push(pbxGroupChild(file));
+}
+
+pbxProject.prototype.removeFromResourcesPbxGroup = function(file) {
+ var pluginsGroupChildren = this.pbxGroupByName('Resources').children, i;
+ for (i in pluginsGroupChildren) {
+ if (pbxGroupChild(file).value == pluginsGroupChildren[i].value &&
+ pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) {
+ pluginsGroupChildren.splice(i, 1);
+ break;
+ }
+ }
+}
+
+pbxProject.prototype.addToFrameworksPbxGroup = function(file) {
+ var pluginsGroup = this.pbxGroupByName('Frameworks');
+ pluginsGroup.children.push(pbxGroupChild(file));
+}
+
+pbxProject.prototype.removeFromFrameworksPbxGroup = function(file) {
+ var pluginsGroupChildren = this.pbxGroupByName('Frameworks').children;
+
+ for (i in pluginsGroupChildren) {
+ if (pbxGroupChild(file).value == pluginsGroupChildren[i].value &&
+ pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) {
+ pluginsGroupChildren.splice(i, 1);
+ break;
+ }
+ }
+}
+
+pbxProject.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) {
+ var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
+ if (sources) {
+ sources.files.push(pbxBuildPhaseObj(file));
+ }
+}
+
+pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) {
+ var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
+ if (sources) {
+ var files = [];
+ for (i in sources.files) {
+ if (sources.files[i].comment != longComment(file)) {
+ files.push(sources.files[i]);
+ }
+ }
+ sources.files = files;
+ }
+}
+
+pbxProject.prototype.addToProductsPbxGroup = function(file) {
+ var productsGroup = this.pbxGroupByName('Products');
+ productsGroup.children.push(pbxGroupChild(file));
+}
+
+pbxProject.prototype.removeFromProductsPbxGroup = function(file) {
+ var productsGroupChildren = this.pbxGroupByName('Products').children, i;
+ for (i in productsGroupChildren) {
+ if (pbxGroupChild(file).value == productsGroupChildren[i].value &&
+ pbxGroupChild(file).comment == productsGroupChildren[i].comment) {
+ productsGroupChildren.splice(i, 1);
+ break;
+ }
+ }
+}
+
+pbxProject.prototype.addToPbxSourcesBuildPhase = function(file) {
+ var sources = this.pbxSourcesBuildPhaseObj(file.target);
+ sources.files.push(pbxBuildPhaseObj(file));
+}
+
+pbxProject.prototype.removeFromPbxSourcesBuildPhase = function(file) {
+
+ var sources = this.pbxSourcesBuildPhaseObj(file.target), i;
+ for (i in sources.files) {
+ if (sources.files[i].comment == longComment(file)) {
+ sources.files.splice(i, 1);
+ break;
+ }
+ }
+}
+
+pbxProject.prototype.addToPbxResourcesBuildPhase = function(file) {
+ var sources = this.pbxResourcesBuildPhaseObj(file.target);
+ sources.files.push(pbxBuildPhaseObj(file));
+}
+
+pbxProject.prototype.removeFromPbxResourcesBuildPhase = function(file) {
+ var sources = this.pbxResourcesBuildPhaseObj(file.target), i;
+
+ for (i in sources.files) {
+ if (sources.files[i].comment == longComment(file)) {
+ sources.files.splice(i, 1);
+ break;
+ }
+ }
+}
+
+pbxProject.prototype.addToPbxFrameworksBuildPhase = function(file) {
+ var sources = this.pbxFrameworksBuildPhaseObj(file.target);
+ sources.files.push(pbxBuildPhaseObj(file));
+}
+
+pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function(file) {
+ var sources = this.pbxFrameworksBuildPhaseObj(file.target);
+ for (i in sources.files) {
+ if (sources.files[i].comment == longComment(file)) {
+ sources.files.splice(i, 1);
+ break;
+ }
+ }
+}
+
+pbxProject.prototype.addXCConfigurationList = function(configurationObjectsArray, defaultConfigurationName, comment) {
+ var pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection(),
+ pbxXCConfigurationListSection = this.pbxXCConfigurationList(),
+ xcConfigurationListUuid = this.generateUuid(),
+ commentKey = f("%s_comment", xcConfigurationListUuid),
+ xcConfigurationList = {
+ isa: 'XCConfigurationList',
+ buildConfigurations: [],
+ defaultConfigurationIsVisible: 0,
+ defaultConfigurationName: defaultConfigurationName
+ };
+
+ for (var index = 0; index < configurationObjectsArray.length; index++) {
+ var configuration = configurationObjectsArray[index],
+ configurationUuid = this.generateUuid(),
+ configurationCommentKey = f("%s_comment", configurationUuid);
+
+ pbxBuildConfigurationSection[configurationUuid] = configuration;
+ pbxBuildConfigurationSection[configurationCommentKey] = configuration.name;
+ xcConfigurationList.buildConfigurations.push({ value: configurationUuid, comment: configuration.name });
+ }
+
+ if (pbxXCConfigurationListSection) {
+ pbxXCConfigurationListSection[xcConfigurationListUuid] = xcConfigurationList;
+ pbxXCConfigurationListSection[commentKey] = comment;
+ }
+
+ return { uuid: xcConfigurationListUuid, xcConfigurationList: xcConfigurationList };
+}
+
+pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
+ if (!target)
+ return undefined;
+
+ var nativeTargets = this.pbxNativeTargetSection();
+
+ if (typeof nativeTargets[target] == "undefined")
+ throw new Error("Invalid target: " + target);
+
+ for (var index = 0; index < dependencyTargets.length; index++) {
+ var dependencyTarget = dependencyTargets[index];
+ if (typeof nativeTargets[dependencyTarget] == "undefined")
+ throw new Error("Invalid target: " + dependencyTarget);
+ }
+
+ var pbxTargetDependency = 'PBXTargetDependency',
+ pbxContainerItemProxy = 'PBXContainerItemProxy',
+ pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency],
+ pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy];
+
+ for (var index = 0; index < dependencyTargets.length; index++) {
+ var dependencyTargetUuid = dependencyTargets[index],
+ dependencyTargetCommentKey = f("%s_comment", dependencyTargetUuid),
+ targetDependencyUuid = this.generateUuid(),
+ targetDependencyCommentKey = f("%s_comment", targetDependencyUuid),
+ itemProxyUuid = this.generateUuid(),
+ itemProxyCommentKey = f("%s_comment", itemProxyUuid),
+ itemProxy = {
+ isa: pbxContainerItemProxy,
+ containerPortal: this.hash.project['rootObject'],
+ containerPortal_comment: this.hash.project['rootObject_comment'],
+ proxyType: 1,
+ remoteGlobalIDString: dependencyTargetUuid,
+ remoteInfo: nativeTargets[dependencyTargetUuid].name
+ },
+ targetDependency = {
+ isa: pbxTargetDependency,
+ target: dependencyTargetUuid,
+ target_comment: nativeTargets[dependencyTargetCommentKey],
+ targetProxy: itemProxyUuid,
+ targetProxy_comment: pbxContainerItemProxy
+ };
+
+ if (pbxContainerItemProxySection && pbxTargetDependencySection) {
+ pbxContainerItemProxySection[itemProxyUuid] = itemProxy;
+ pbxContainerItemProxySection[itemProxyCommentKey] = pbxContainerItemProxy;
+ pbxTargetDependencySection[targetDependencyUuid] = targetDependency;
+ pbxTargetDependencySection[targetDependencyCommentKey] = pbxTargetDependency;
+ nativeTargets[target].dependencies.push({ value: targetDependencyUuid, comment: pbxTargetDependency })
+ }
+ }
+
+ return { uuid: target, target: nativeTargets[target] };
+}
+
+pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, comment, target, optionsOrFolderType, subfolderPath) {
+ var buildPhaseSection,
+ fileReferenceSection = this.pbxFileReferenceSection(),
+ buildFileSection = this.pbxBuildFileSection(),
+ buildPhaseUuid = this.generateUuid(),
+ buildPhaseTargetUuid = target || this.getFirstTarget().uuid,
+ commentKey = f("%s_comment", buildPhaseUuid),
+ buildPhase = {
+ isa: buildPhaseType,
+ buildActionMask: 2147483647,
+ files: [],
+ runOnlyForDeploymentPostprocessing: 0
+ },
+ filePathToBuildFile = {};
+
+ if (buildPhaseType === 'PBXCopyFilesBuildPhase') {
+ buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, optionsOrFolderType, subfolderPath, comment);
+ } else if (buildPhaseType === 'PBXShellScriptBuildPhase') {
+ buildPhase = pbxShellScriptBuildPhaseObj(buildPhase, optionsOrFolderType, comment)
+ }
+
+ if (!this.hash.project.objects[buildPhaseType]) {
+ this.hash.project.objects[buildPhaseType] = new Object();
+ }
+
+ if (!this.hash.project.objects[buildPhaseType][buildPhaseUuid]) {
+ this.hash.project.objects[buildPhaseType][buildPhaseUuid] = buildPhase;
+ this.hash.project.objects[buildPhaseType][commentKey] = comment;
+ }
+
+ if (this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases']) {
+ this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases'].push({
+ value: buildPhaseUuid,
+ comment: comment
+ })
+
+ }
+
+
+ for (var key in buildFileSection) {
+ // only look for comments
+ if (!COMMENT_KEY.test(key)) continue;
+
+ var buildFileKey = key.split(COMMENT_KEY)[0],
+ buildFile = buildFileSection[buildFileKey];
+ fileReference = fileReferenceSection[buildFile.fileRef];
+
+ if (!fileReference) continue;
+
+ var pbxFileObj = new pbxFile(fileReference.path);
+
+ filePathToBuildFile[fileReference.path] = { uuid: buildFileKey, basename: pbxFileObj.basename, group: pbxFileObj.group };
+ }
+
+ for (var index = 0; index < filePathsArray.length; index++) {
+ var filePath = filePathsArray[index],
+ filePathQuoted = "\"" + filePath + "\"",
+ file = new pbxFile(filePath);
+
+ if (filePathToBuildFile[filePath]) {
+ buildPhase.files.push(pbxBuildPhaseObj(filePathToBuildFile[filePath]));
+ continue;
+ } else if (filePathToBuildFile[filePathQuoted]) {
+ buildPhase.files.push(pbxBuildPhaseObj(filePathToBuildFile[filePathQuoted]));
+ continue;
+ }
+
+ file.uuid = this.generateUuid();
+ file.fileRef = this.generateUuid();
+ this.addToPbxFileReferenceSection(file); // PBXFileReference
+ this.addToPbxBuildFileSection(file); // PBXBuildFile
+ buildPhase.files.push(pbxBuildPhaseObj(file));
+ }
+
+ if (buildPhaseSection) {
+ buildPhaseSection[buildPhaseUuid] = buildPhase;
+ buildPhaseSection[commentKey] = comment;
+ }
+
+ return { uuid: buildPhaseUuid, buildPhase: buildPhase };
+}
+
+// helper access functions
+pbxProject.prototype.pbxProjectSection = function() {
+ return this.hash.project.objects['PBXProject'];
+}
+pbxProject.prototype.pbxBuildFileSection = function() {
+ return this.hash.project.objects['PBXBuildFile'];
+}
+
+pbxProject.prototype.pbxXCBuildConfigurationSection = function() {
+ return this.hash.project.objects['XCBuildConfiguration'];
+}
+
+pbxProject.prototype.pbxFileReferenceSection = function() {
+ return this.hash.project.objects['PBXFileReference'];
+}
+
+pbxProject.prototype.pbxNativeTargetSection = function() {
+ return this.hash.project.objects['PBXNativeTarget'];
+}
+
+pbxProject.prototype.xcVersionGroupSection = function () {
+ if (typeof this.hash.project.objects['XCVersionGroup'] !== 'object') {
+ this.hash.project.objects['XCVersionGroup'] = {};
+ }
+
+ return this.hash.project.objects['XCVersionGroup'];
+}
+
+pbxProject.prototype.pbxXCConfigurationList = function() {
+ return this.hash.project.objects['XCConfigurationList'];
+}
+
+pbxProject.prototype.pbxGroupByName = function(name) {
+ var groups = this.hash.project.objects['PBXGroup'],
+ key, groupKey;
+
+ for (key in groups) {
+ // only look for comments
+ if (!COMMENT_KEY.test(key)) continue;
+
+ if (groups[key] == name) {
+ groupKey = key.split(COMMENT_KEY)[0];
+ return groups[groupKey];
+ }
+ }
+
+ return null;
+}
+
+pbxProject.prototype.pbxTargetByName = function(name) {
+ return this.pbxItemByComment(name, 'PBXNativeTarget');
+}
+
+pbxProject.prototype.findTargetKey = function(name) {
+ var targets = this.hash.project.objects['PBXNativeTarget'];
+
+ for (var key in targets) {
+ // only look for comments
+ if (COMMENT_KEY.test(key)) continue;
+
+ var target = targets[key];
+ if (target.name === name) {
+ return key;
+ }
+ }
+
+ return null;
+}
+
+pbxProject.prototype.pbxItemByComment = function(name, pbxSectionName) {
+ var section = this.hash.project.objects[pbxSectionName],
+ key, itemKey;
+
+ for (key in section) {
+ // only look for comments
+ if (!COMMENT_KEY.test(key)) continue;
+
+ if (section[key] == name) {
+ itemKey = key.split(COMMENT_KEY)[0];
+ return section[itemKey];
+ }
+ }
+
+ return null;
+}
+
+pbxProject.prototype.pbxSourcesBuildPhaseObj = function(target) {
+ return this.buildPhaseObject('PBXSourcesBuildPhase', 'Sources', target);
+}
+
+pbxProject.prototype.pbxResourcesBuildPhaseObj = function(target) {
+ return this.buildPhaseObject('PBXResourcesBuildPhase', 'Resources', target);
+}
+
+pbxProject.prototype.pbxFrameworksBuildPhaseObj = function(target) {
+ return this.buildPhaseObject('PBXFrameworksBuildPhase', 'Frameworks', target);
+}
+
+pbxProject.prototype.pbxEmbedFrameworksBuildPhaseObj = function (target) {
+ return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Frameworks', target);
+};
+
+// Find Build Phase from group/target
+pbxProject.prototype.buildPhase = function(group, target) {
+
+ if (!target)
+ return undefined;
+
+ var nativeTargets = this.pbxNativeTargetSection();
+ if (typeof nativeTargets[target] == "undefined")
+ throw new Error("Invalid target: " + target);
+
+ var nativeTarget = nativeTargets[target];
+ var buildPhases = nativeTarget.buildPhases;
+ for(var i in buildPhases)
+ {
+ var buildPhase = buildPhases[i];
+ if (buildPhase.comment==group)
+ return buildPhase.value + "_comment";
+ }
+ }
+
+pbxProject.prototype.buildPhaseObject = function(name, group, target) {
+ var section = this.hash.project.objects[name],
+ obj, sectionKey, key;
+ var buildPhase = this.buildPhase(group, target);
+
+ for (key in section) {
+
+ // only look for comments
+ if (!COMMENT_KEY.test(key)) continue;
+
+ // select the proper buildPhase
+ if (buildPhase && buildPhase!=key)
+ continue;
+ if (section[key] == group) {
+ sectionKey = key.split(COMMENT_KEY)[0];
+ return section[sectionKey];
+ }
+ }
+ return null;
+}
+
+pbxProject.prototype.addBuildProperty = function(prop, value, build_name) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ key, configuration;
+
+ for (key in configurations){
+ configuration = configurations[key];
+ if (!build_name || configuration.name === build_name){
+ configuration.buildSettings[prop] = value;
+ }
+ }
+}
+
+pbxProject.prototype.removeBuildProperty = function(prop, build_name) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ key, configuration;
+
+ for (key in configurations){
+ configuration = configurations[key];
+ if (configuration.buildSettings[prop] &&
+ !build_name || configuration.name === build_name){
+ delete configuration.buildSettings[prop];
+ }
+ }
+}
+
+/**
+ *
+ * @param prop {String}
+ * @param value {String|Array|Object|Number|Boolean}
+ * @param build {String} Release or Debug
+ */
+pbxProject.prototype.updateBuildProperty = function(prop, value, build) {
+ var configs = this.pbxXCBuildConfigurationSection();
+ for (var configName in configs) {
+ if (!COMMENT_KEY.test(configName)) {
+ var config = configs[configName];
+ if ( (build && config.name === build) || (!build) ) {
+ config.buildSettings[prop] = value;
+ }
+ }
+ }
+}
+
+pbxProject.prototype.updateProductName = function(name) {
+ this.updateBuildProperty('PRODUCT_NAME', '"' + name + '"');
+}
+
+pbxProject.prototype.removeFromFrameworkSearchPaths = function(file) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ INHERITED = '"$(inherited)"',
+ SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS',
+ config, buildSettings, searchPaths;
+ var new_path = searchPathForFile(file, this);
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (unquote(buildSettings['PRODUCT_NAME']) != this.productName)
+ continue;
+
+ searchPaths = buildSettings[SEARCH_PATHS];
+
+ if (searchPaths) {
+ var matches = searchPaths.filter(function(p) {
+ return p.indexOf(new_path) > -1;
+ });
+ matches.forEach(function(m) {
+ var idx = searchPaths.indexOf(m);
+ searchPaths.splice(idx, 1);
+ });
+ }
+ }
+}
+
+pbxProject.prototype.addToFrameworkSearchPaths = function(file) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ INHERITED = '"$(inherited)"',
+ config, buildSettings, searchPaths;
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (unquote(buildSettings['PRODUCT_NAME']) != this.productName)
+ continue;
+
+ if (!buildSettings['FRAMEWORK_SEARCH_PATHS']
+ || buildSettings['FRAMEWORK_SEARCH_PATHS'] === INHERITED) {
+ buildSettings['FRAMEWORK_SEARCH_PATHS'] = [INHERITED];
+ }
+
+ buildSettings['FRAMEWORK_SEARCH_PATHS'].push(searchPathForFile(file, this));
+ }
+}
+
+pbxProject.prototype.removeFromLibrarySearchPaths = function(file) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ INHERITED = '"$(inherited)"',
+ SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS',
+ config, buildSettings, searchPaths;
+ var new_path = searchPathForFile(file, this);
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (unquote(buildSettings['PRODUCT_NAME']) != this.productName)
+ continue;
+
+ searchPaths = buildSettings[SEARCH_PATHS];
+
+ if (searchPaths) {
+ var matches = searchPaths.filter(function(p) {
+ return p.indexOf(new_path) > -1;
+ });
+ matches.forEach(function(m) {
+ var idx = searchPaths.indexOf(m);
+ searchPaths.splice(idx, 1);
+ });
+ }
+
+ }
+}
+
+pbxProject.prototype.addToLibrarySearchPaths = function(file) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ INHERITED = '"$(inherited)"',
+ config, buildSettings, searchPaths;
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (unquote(buildSettings['PRODUCT_NAME']) != this.productName)
+ continue;
+
+ if (!buildSettings['LIBRARY_SEARCH_PATHS']
+ || buildSettings['LIBRARY_SEARCH_PATHS'] === INHERITED) {
+ buildSettings['LIBRARY_SEARCH_PATHS'] = [INHERITED];
+ }
+
+ if (typeof file === 'string') {
+ buildSettings['LIBRARY_SEARCH_PATHS'].push(file);
+ } else {
+ buildSettings['LIBRARY_SEARCH_PATHS'].push(searchPathForFile(file, this));
+ }
+ }
+}
+
+pbxProject.prototype.removeFromHeaderSearchPaths = function(file) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ INHERITED = '"$(inherited)"',
+ SEARCH_PATHS = 'HEADER_SEARCH_PATHS',
+ config, buildSettings, searchPaths;
+ var new_path = searchPathForFile(file, this);
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (unquote(buildSettings['PRODUCT_NAME']) != this.productName)
+ continue;
+
+ if (buildSettings[SEARCH_PATHS]) {
+ var matches = buildSettings[SEARCH_PATHS].filter(function(p) {
+ return p.indexOf(new_path) > -1;
+ });
+ matches.forEach(function(m) {
+ var idx = buildSettings[SEARCH_PATHS].indexOf(m);
+ buildSettings[SEARCH_PATHS].splice(idx, 1);
+ });
+ }
+
+ }
+}
+pbxProject.prototype.addToHeaderSearchPaths = function(file) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ INHERITED = '"$(inherited)"',
+ config, buildSettings, searchPaths;
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (unquote(buildSettings['PRODUCT_NAME']) != this.productName)
+ continue;
+
+ if (!buildSettings['HEADER_SEARCH_PATHS']) {
+ buildSettings['HEADER_SEARCH_PATHS'] = [INHERITED];
+ }
+
+ if (typeof file === 'string') {
+ buildSettings['HEADER_SEARCH_PATHS'].push(file);
+ } else {
+ buildSettings['HEADER_SEARCH_PATHS'].push(searchPathForFile(file, this));
+ }
+ }
+}
+
+pbxProject.prototype.addToOtherLinkerFlags = function (flag) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ INHERITED = '"$(inherited)"',
+ OTHER_LDFLAGS = 'OTHER_LDFLAGS',
+ config, buildSettings;
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (unquote(buildSettings['PRODUCT_NAME']) != this.productName)
+ continue;
+
+ if (!buildSettings[OTHER_LDFLAGS]
+ || buildSettings[OTHER_LDFLAGS] === INHERITED) {
+ buildSettings[OTHER_LDFLAGS] = [INHERITED];
+ }
+
+ buildSettings[OTHER_LDFLAGS].push(flag);
+ }
+}
+
+pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ OTHER_LDFLAGS = 'OTHER_LDFLAGS',
+ config, buildSettings;
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) {
+ continue;
+ }
+
+ if (buildSettings[OTHER_LDFLAGS]) {
+ var matches = buildSettings[OTHER_LDFLAGS].filter(function (p) {
+ return p.indexOf(flag) > -1;
+ });
+ matches.forEach(function (m) {
+ var idx = buildSettings[OTHER_LDFLAGS].indexOf(m);
+ buildSettings[OTHER_LDFLAGS].splice(idx, 1);
+ });
+ }
+ }
+}
+
+pbxProject.prototype.addToBuildSettings = function (buildSetting, value) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ config, buildSettings;
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ buildSettings[buildSetting] = value;
+ }
+}
+
+pbxProject.prototype.removeFromBuildSettings = function (buildSetting) {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ config, buildSettings;
+
+ for (config in configurations) {
+ buildSettings = configurations[config].buildSettings;
+
+ if (buildSettings[buildSetting]) {
+ delete buildSettings[buildSetting];
+ }
+ }
+}
+
+// a JS getter. hmmm
+pbxProject.prototype.__defineGetter__("productName", function() {
+ var configurations = nonComments(this.pbxXCBuildConfigurationSection()),
+ config, productName;
+
+ for (config in configurations) {
+ productName = configurations[config].buildSettings['PRODUCT_NAME'];
+
+ if (productName) {
+ return unquote(productName);
+ }
+ }
+});
+
+// check if file is present
+pbxProject.prototype.hasFile = function(filePath) {
+ var files = nonComments(this.pbxFileReferenceSection()),
+ file, id;
+ for (id in files) {
+ file = files[id];
+ if (file.path == filePath || file.path == ('"' + filePath + '"')) {
+ return file;
+ }
+ }
+
+ return false;
+}
+
+pbxProject.prototype.addTarget = function(name, type, subfolder) {
+
+ // Setup uuid and name of new target
+ var targetUuid = this.generateUuid(),
+ targetType = type,
+ targetSubfolder = subfolder || name,
+ targetName = name.trim();
+
+ // Check type against list of allowed target types
+ if (!targetName) {
+ throw new Error("Target name missing.");
+ }
+
+ // Check type against list of allowed target types
+ if (!targetType) {
+ throw new Error("Target type missing.");
+ }
+
+ // Check type against list of allowed target types
+ if (!producttypeForTargettype(targetType)) {
+ throw new Error("Target type invalid: " + targetType);
+ }
+
+ // Build Configuration: Create
+ var buildConfigurationsList = [
+ {
+ name: 'Debug',
+ isa: 'XCBuildConfiguration',
+ buildSettings: {
+ GCC_PREPROCESSOR_DEFINITIONS: ['"DEBUG=1"', '"$(inherited)"'],
+ INFOPLIST_FILE: '"' + path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'),
+ LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"',
+ PRODUCT_NAME: '"' + targetName + '"',
+ SKIP_INSTALL: 'YES'
+ }
+ },
+ {
+ name: 'Release',
+ isa: 'XCBuildConfiguration',
+ buildSettings: {
+ INFOPLIST_FILE: '"' + path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'),
+ LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"',
+ PRODUCT_NAME: '"' + targetName + '"',
+ SKIP_INSTALL: 'YES'
+ }
+ }
+ ];
+
+ // Build Configuration: Add
+ var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName +'"');
+
+ // Product: Create
+ var productName = targetName,
+ productType = producttypeForTargettype(targetType),
+ productFileType = filetypeForProducttype(productType),
+ productFile = this.addProductFile(productName, { group: 'Copy Files', 'target': targetUuid, 'explicitFileType': productFileType}),
+ productFileName = productFile.basename;
+
+
+ // Product: Add to build file list
+ this.addToPbxBuildFileSection(productFile);
+
+ // Target: Create
+ var target = {
+ uuid: targetUuid,
+ pbxNativeTarget: {
+ isa: 'PBXNativeTarget',
+ name: '"' + targetName + '"',
+ productName: '"' + targetName + '"',
+ productReference: productFile.fileRef,
+ productType: '"' + producttypeForTargettype(targetType) + '"',
+ buildConfigurationList: buildConfigurations.uuid,
+ buildPhases: [],
+ buildRules: [],
+ dependencies: []
+ }
+ };
+
+ // Target: Add to PBXNativeTarget section
+ this.addToPbxNativeTargetSection(target)
+
+ // Product: Embed (only for "extension"-type targets)
+ if (targetType === 'app_extension') {
+
+ // Create CopyFiles phase in first target
+ this.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Copy Files', this.getFirstTarget().uuid, targetType)
+
+ // Add product to CopyFiles phase
+ this.addToPbxCopyfilesBuildPhase(productFile)
+
+ // this.addBuildPhaseToTarget(newPhase.buildPhase, this.getFirstTarget().uuid)
+
+ };
+
+ // Target: Add uuid to root project
+ this.addToPbxProjectSection(target);
+
+ // Target: Add dependency for this target to first (main) target
+ this.addTargetDependency(this.getFirstTarget().uuid, [target.uuid]);
+
+
+ // Return target on success
+ return target;
+
+};
+
+// helper recursive prop search+replace
+function propReplace(obj, prop, value) {
+ var o = {};
+ for (var p in obj) {
+ if (o.hasOwnProperty.call(obj, p)) {
+ if (typeof obj[p] == 'object' && !Array.isArray(obj[p])) {
+ propReplace(obj[p], prop, value);
+ } else if (p == prop) {
+ obj[p] = value;
+ }
+ }
+ }
+}
+
+// helper object creation functions
+function pbxBuildFileObj(file) {
+ var obj = Object.create(null);
+
+ obj.isa = 'PBXBuildFile';
+ obj.fileRef = file.fileRef;
+ obj.fileRef_comment = file.basename;
+ if (file.settings) obj.settings = file.settings;
+
+ return obj;
+}
+
+function pbxFileReferenceObj(file) {
+ var fileObject = {
+ isa: "PBXFileReference",
+ name: "\"" + file.basename + "\"",
+ path: "\"" + file.path.replace(/\\/g, '/') + "\"",
+ sourceTree: file.sourceTree,
+ fileEncoding: file.fileEncoding,
+ lastKnownFileType: file.lastKnownFileType,
+ explicitFileType: file.explicitFileType,
+ includeInIndex: file.includeInIndex
+ };
+
+ return fileObject;
+}
+
+function pbxGroupChild(file) {
+ var obj = Object.create(null);
+
+ obj.value = file.fileRef;
+ obj.comment = file.basename;
+
+ return obj;
+}
+
+function pbxBuildPhaseObj(file) {
+ var obj = Object.create(null);
+
+ obj.value = file.uuid;
+ obj.comment = longComment(file);
+
+ return obj;
+}
+
+function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) {
+
+ // Add additional properties for 'CopyFiles' build phase
+ var DESTINATION_BY_TARGETTYPE = {
+ application: 'wrapper',
+ app_extension: 'plugins',
+ bundle: 'wrapper',
+ command_line_tool: 'wrapper',
+ dynamic_library: 'products_directory',
+ framework: 'shared_frameworks',
+ frameworks: 'frameworks',
+ static_library: 'products_directory',
+ unit_test_bundle: 'wrapper',
+ watch_app: 'wrapper',
+ watch_extension: 'plugins'
+ }
+ var SUBFOLDERSPEC_BY_DESTINATION = {
+ absolute_path: 0,
+ executables: 6,
+ frameworks: 10,
+ java_resources: 15,
+ plugins: 13,
+ products_directory: 16,
+ resources: 7,
+ shared_frameworks: 11,
+ shared_support: 12,
+ wrapper: 1,
+ xpc_services: 0
+ }
+
+ obj.name = '"' + phaseName + '"';
+ obj.dstPath = subfolderPath || '""';
+ obj.dstSubfolderSpec = SUBFOLDERSPEC_BY_DESTINATION[DESTINATION_BY_TARGETTYPE[folderType]];
+
+ return obj;
+}
+
+function pbxShellScriptBuildPhaseObj(obj, options, phaseName) {
+ obj.name = '"' + phaseName + '"';
+ obj.inputPaths = options.inputPaths || [];
+ obj.outputPaths = options.outputPaths || [];
+ obj.shellPath = options.shellPath;
+ obj.shellScript = '"' + options.shellScript.replace(/"/g, '\\"') + '"';
+
+ return obj;
+}
+
+function pbxBuildFileComment(file) {
+ return longComment(file);
+}
+
+function pbxFileReferenceComment(file) {
+ return file.basename || path.basename(file.path);
+}
+
+function pbxNativeTargetComment(target) {
+ return target.name;
+}
+
+function longComment(file) {
+ return f("%s in %s", file.basename, file.group);
+}
+
+// respect <group> path
+function correctForPluginsPath(file, project) {
+ return correctForPath(file, project, 'Plugins');
+}
+
+function correctForResourcesPath(file, project) {
+ return correctForPath(file, project, 'Resources');
+}
+
+function correctForFrameworksPath(file, project) {
+ return correctForPath(file, project, 'Frameworks');
+}
+
+function correctForPath(file, project, group) {
+ var r_group_dir = new RegExp('^' + group + '[\\\\/]');
+
+ if (project.pbxGroupByName(group).path)
+ file.path = file.path.replace(r_group_dir, '');
+
+ return file;
+}
+
+function searchPathForFile(file, proj) {
+ var plugins = proj.pbxGroupByName('Plugins'),
+ pluginsPath = plugins ? plugins.path : null,
+ fileDir = path.dirname(file.path);
+
+ if (fileDir == '.') {
+ fileDir = '';
+ } else {
+ fileDir = '/' + fileDir;
+ }
+
+ if (file.plugin && pluginsPath) {
+ return '"\\"$(SRCROOT)/' + unquote(pluginsPath) + '\\""';
+ } else if (file.customFramework && file.dirname) {
+ return '"\\"' + file.dirname + '\\""';
+ } else {
+ return '"\\"$(SRCROOT)/' + proj.productName + fileDir + '\\""';
+ }
+}
+
+function nonComments(obj) {
+ var keys = Object.keys(obj),
+ newObj = {}, i = 0;
+
+ for (i; i < keys.length; i++) {
+ if (!COMMENT_KEY.test(keys[i])) {
+ newObj[keys[i]] = obj[keys[i]];
+ }
+ }
+
+ return newObj;
+}
+
+function unquote(str) {
+ if (str) return str.replace(/^"(.*)"$/, "$1");
+}
+
+
+function buildPhaseNameForIsa (isa) {
+
+ BUILDPHASENAME_BY_ISA = {
+ PBXCopyFilesBuildPhase: 'Copy Files',
+ PBXResourcesBuildPhase: 'Resources',
+ PBXSourcesBuildPhase: 'Sources',
+ PBXFrameworksBuildPhase: 'Frameworks'
+ }
+
+ return BUILDPHASENAME_BY_ISA[isa]
+}
+
+function producttypeForTargettype (targetType) {
+
+ PRODUCTTYPE_BY_TARGETTYPE = {
+ application: 'com.apple.product-type.application',
+ app_extension: 'com.apple.product-type.app-extension',
+ bundle: 'com.apple.product-type.bundle',
+ command_line_tool: 'com.apple.product-type.tool',
+ dynamic_library: 'com.apple.product-type.library.dynamic',
+ framework: 'com.apple.product-type.framework',
+ static_library: 'com.apple.product-type.library.static',
+ unit_test_bundle: 'com.apple.product-type.bundle.unit-test',
+ watch_app: 'com.apple.product-type.application.watchapp',
+ watch_extension: 'com.apple.product-type.watchkit-extension'
+ };
+
+ return PRODUCTTYPE_BY_TARGETTYPE[targetType]
+}
+
+function filetypeForProducttype (productType) {
+
+ FILETYPE_BY_PRODUCTTYPE = {
+ 'com.apple.product-type.application': '"wrapper.application"',
+ 'com.apple.product-type.app-extension': '"wrapper.app-extension"',
+ 'com.apple.product-type.bundle': '"wrapper.plug-in"',
+ 'com.apple.product-type.tool': '"compiled.mach-o.dylib"',
+ 'com.apple.product-type.library.dynamic': '"compiled.mach-o.dylib"',
+ 'com.apple.product-type.framework': '"wrapper.framework"',
+ 'com.apple.product-type.library.static': '"archive.ar"',
+ 'com.apple.product-type.bundle.unit-test': '"wrapper.cfbundle"',
+ 'com.apple.product-type.application.watchapp': '"wrapper.application"',
+ 'com.apple.product-type.watchkit-extension': '"wrapper.app-extension"'
+ };
+
+ return FILETYPE_BY_PRODUCTTYPE[productType]
+}
+
+pbxProject.prototype.getFirstProject = function() {
+
+ // Get pbxProject container
+ var pbxProjectContainer = this.pbxProjectSection();
+
+ // Get first pbxProject UUID
+ var firstProjectUuid = Object.keys(pbxProjectContainer)[0];
+
+ // Get first pbxProject
+ var firstProject = pbxProjectContainer[firstProjectUuid];
+
+ return {
+ uuid: firstProjectUuid,
+ firstProject: firstProject
+ }
+}
+
+pbxProject.prototype.getFirstTarget = function() {
+
+ // Get first targets UUID
+ var firstTargetUuid = this.getFirstProject()['firstProject']['targets'][0].value;
+
+ // Get first pbxNativeTarget
+ var firstTarget = this.pbxNativeTargetSection()[firstTargetUuid];
+
+ return {
+ uuid: firstTargetUuid,
+ firstTarget: firstTarget
+ }
+}
+
+/*** NEW ***/
+
+pbxProject.prototype.addToPbxGroupType = function (file, groupKey, groupType) {
+ var group = this.getPBXGroupByKeyAndType(groupKey, groupType);
+ if (group && group.children !== undefined) {
+ if (typeof file === 'string') {
+ //Group Key
+ var childGroup = {
+ value:file,
+ };
+ if (this.getPBXGroupByKey(file)) {
+ childGroup.comment = this.getPBXGroupByKey(file).name;
+ }
+ else if (this.getPBXVariantGroupByKey(file)) {
+ childGroup.comment = this.getPBXVariantGroupByKey(file).name;
+ }
+
+ group.children.push(childGroup);
+ }
+ else {
+ //File Object
+ group.children.push(pbxGroupChild(file));
+ }
+ }
+}
+
+pbxProject.prototype.addToPbxVariantGroup = function (file, groupKey) {
+ this.addToPbxGroupType(file, groupKey, 'PBXVariantGroup');
+}
+
+pbxProject.prototype.addToPbxGroup = function (file, groupKey) {
+ this.addToPbxGroupType(file, groupKey, 'PBXGroup');
+}
+
+
+
+pbxProject.prototype.pbxCreateGroupWithType = function(name, pathName, groupType) {
+ //Create object
+ var model = {
+ isa: '"' + groupType + '"',
+ children: [],
+ name: name,
+ sourceTree: '"<group>"'
+ };
+ if (pathName) model.path = pathName;
+ var key = this.generateUuid();
+
+ //Create comment
+ var commendId = key + '_comment';
+
+ //add obj and commentObj to groups;
+ var groups = this.hash.project.objects[groupType];
+ if (!groups) {
+ groups = this.hash.project.objects[groupType] = new Object();
+ }
+ groups[commendId] = name;
+ groups[key] = model;
+
+ return key;
+}
+
+pbxProject.prototype.pbxCreateVariantGroup = function(name) {
+ return this.pbxCreateGroupWithType(name, undefined, 'PBXVariantGroup')
+}
+
+pbxProject.prototype.pbxCreateGroup = function(name, pathName) {
+ return this.pbxCreateGroupWithType(name, pathName, 'PBXGroup');
+}
+
+
+
+pbxProject.prototype.removeFromPbxGroupAndType = function (file, groupKey, groupType) {
+ var group = this.getPBXGroupByKeyAndType(groupKey, groupType);
+ if (group) {
+ var groupChildren = group.children, i;
+ for(i in groupChildren) {
+ if(pbxGroupChild(file).value == groupChildren[i].value &&
+ pbxGroupChild(file).comment == groupChildren[i].comment) {
+ groupChildren.splice(i, 1);
+ break;
+ }
+ }
+ }
+}
+
+pbxProject.prototype.removeFromPbxGroup = function (file, groupKey) {
+ this.removeFromPbxGroupAndType(file, groupKey, 'PBXGroup');
+}
+
+pbxProject.prototype.removeFromPbxVariantGroup = function (file, groupKey) {
+ this.removeFromPbxGroupAndType(file, groupKey, 'PBXVariantGroup');
+}
+
+
+
+pbxProject.prototype.getPBXGroupByKeyAndType = function(key, groupType) {
+ return this.hash.project.objects[groupType][key];
+};
+
+pbxProject.prototype.getPBXGroupByKey = function(key) {
+ return this.hash.project.objects['PBXGroup'][key];
+};
+
+pbxProject.prototype.getPBXVariantGroupByKey = function(key) {
+ return this.hash.project.objects['PBXVariantGroup'][key];
+};
+
+
+
+pbxProject.prototype.findPBXGroupKeyAndType = function(criteria, groupType) {
+ var groups = this.hash.project.objects[groupType];
+ var target;
+
+ for (var key in groups) {
+ // only look for comments
+ if (COMMENT_KEY.test(key)) continue;
+
+ var group = groups[key];
+ if (criteria && criteria.path && criteria.name) {
+ if (criteria.path === group.path && criteria.name === group.name) {
+ target = key;
+ break
+ }
+ }
+ else if (criteria && criteria.path) {
+ if (criteria.path === group.path) {
+ target = key;
+ break
+ }
+ }
+ else if (criteria && criteria.name) {
+ if (criteria.name === group.name) {
+ target = key;
+ break
+ }
+ }
+ }
+
+ return target;
+}
+
+pbxProject.prototype.findPBXGroupKey = function(criteria) {
+ return this.findPBXGroupKeyAndType(criteria, 'PBXGroup');
+}
+
+pbxProject.prototype.findPBXVariantGroupKey = function(criteria) {
+ return this.findPBXGroupKeyAndType(criteria, 'PBXVariantGroup');
+}
+
+pbxProject.prototype.addLocalizationVariantGroup = function(name) {
+ var groupKey = this.pbxCreateVariantGroup(name);
+
+ var resourceGroupKey = this.findPBXGroupKey({name: 'Resources'});
+ this.addToPbxGroup(groupKey, resourceGroupKey);
+
+ var localizationVariantGroup = {
+ uuid: this.generateUuid(),
+ fileRef: groupKey,
+ basename: name
+ }
+ this.addToPbxBuildFileSection(localizationVariantGroup); // PBXBuildFile
+ this.addToPbxResourcesBuildPhase(localizationVariantGroup); //PBXResourcesBuildPhase
+
+ return localizationVariantGroup;
+};
+
+pbxProject.prototype.addKnownRegion = function (name) {
+ if (!this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']) {
+ this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'] = [];
+ }
+ if (!this.hasKnownRegion(name)) {
+ this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'].push(name);
+ }
+}
+
+pbxProject.prototype.removeKnownRegion = function (name) {
+ var regions = this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'];
+ if (regions) {
+ for (var i = 0; i < regions.length; i++) {
+ if (regions[i] === name) {
+ regions.splice(i, 1);
+ break;
+ }
+ }
+ this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'] = regions;
+ }
+}
+
+pbxProject.prototype.hasKnownRegion = function (name) {
+ var regions = this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'];
+ if (regions) {
+ for (var i in regions) {
+ if (regions[i] === name) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+pbxProject.prototype.getPBXObject = function(name) {
+ return this.hash.project.objects[name];
+}
+
+
+
+pbxProject.prototype.addFile = function (path, group, opt) {
+ var file = new pbxFile(path, opt);
+
+ // null is better for early errors
+ if (this.hasFile(file.path)) return null;
+
+ file.fileRef = this.generateUuid();
+
+ this.addToPbxFileReferenceSection(file); // PBXFileReference
+
+ if (this.getPBXGroupByKey(group)) {
+ this.addToPbxGroup(file, group); // PBXGroup
+ }
+ else if (this.getPBXVariantGroupByKey(group)) {
+ this.addToPbxVariantGroup(file, group); // PBXVariantGroup
+ }
+
+ return file;
+}
+
+pbxProject.prototype.removeFile = function (path, group, opt) {
+ var file = new pbxFile(path, opt);
+
+ this.removeFromPbxFileReferenceSection(file); // PBXFileReference
+
+ if (this.getPBXGroupByKey(group)) {
+ this.removeFromPbxGroup(file, group); // PBXGroup
+ }
+ else if (this.getPBXVariantGroupByKey(group)) {
+ this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup
+ }
+
+ return file;
+}
+
+
+
+pbxProject.prototype.getBuildProperty = function(prop, build) {
+ var target;
+ var configs = this.pbxXCBuildConfigurationSection();
+ for (var configName in configs) {
+ if (!COMMENT_KEY.test(configName)) {
+ var config = configs[configName];
+ if ( (build && config.name === build) || (build === undefined) ) {
+ if (config.buildSettings[prop] !== undefined) {
+ target = config.buildSettings[prop];
+ }
+ }
+ }
+ }
+ return target;
+}
+
+pbxProject.prototype.getBuildConfigByName = function(name) {
+ var target = {};
+ var configs = this.pbxXCBuildConfigurationSection();
+ for (var configName in configs) {
+ if (!COMMENT_KEY.test(configName)) {
+ var config = configs[configName];
+ if (config.name === name) {
+ target[configName] = config;
+ }
+ }
+ }
+ return target;
+}
+
+pbxProject.prototype.addDataModelDocument = function(filePath, group, opt) {
+ if (!group) {
+ group = 'Resources';
+ }
+ if (!this.getPBXGroupByKey(group)) {
+ group = this.findPBXGroupKey({ name: group });
+ }
+
+ var file = new pbxFile(filePath, opt);
+
+ if (!file || this.hasFile(file.path)) return null;
+
+ file.fileRef = this.generateUuid();
+ this.addToPbxGroup(file, group);
+
+ if (!file) return false;
+
+ file.target = opt ? opt.target : undefined;
+ file.uuid = this.generateUuid();
+
+ this.addToPbxBuildFileSection(file);
+ this.addToPbxSourcesBuildPhase(file);
+
+ file.models = [];
+ var currentVersionName;
+ var modelFiles = fs.readdirSync(file.path);
+ for (var index in modelFiles) {
+ var modelFileName = modelFiles[index];
+ var modelFilePath = path.join(filePath, modelFileName);
+
+ if (modelFileName == '.xccurrentversion') {
+ currentVersionName = plist.readFileSync(modelFilePath)._XCCurrentVersionName;
+ continue;
+ }
+
+ var modelFile = new pbxFile(modelFilePath);
+ modelFile.fileRef = this.generateUuid();
+
+ this.addToPbxFileReferenceSection(modelFile);
+
+ file.models.push(modelFile);
+
+ if (currentVersionName && currentVersionName === modelFileName) {
+ file.currentModel = modelFile;
+ }
+ }
+
+ if (!file.currentModel) {
+ file.currentModel = file.models[0];
+ }
+
+ this.addToXcVersionGroupSection(file);
+
+ 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/cordova/node_modules/xcode/lib/pbxWriter.js b/cordova/node_modules/xcode/lib/pbxWriter.js
new file mode 100755
index 0000000..a65bcf1
--- /dev/null
+++ b/cordova/node_modules/xcode/lib/pbxWriter.js
@@ -0,0 +1,282 @@
+var pbxProj = require('./pbxProject'),
+ util = require('util'),
+ f = util.format,
+ INDENT = '\t',
+ COMMENT_KEY = /_comment$/,
+ QUOTED = /^"(.*)"$/,
+ EventEmitter = require('events').EventEmitter
+
+// indentation
+function i(x) {
+ if (x <=0)
+ return '';
+ else
+ return INDENT + i(x-1);
+}
+
+function comment(key, parent) {
+ var text = parent[key + '_comment'];
+
+ if (text)
+ return text;
+ else
+ return null;
+}
+
+// copied from underscore
+function isObject(obj) {
+ return obj === Object(obj)
+}
+
+function isArray(obj) {
+ return Array.isArray(obj)
+}
+
+function pbxWriter(contents) {
+ this.contents = contents;
+ this.sync = false;
+ this.indentLevel = 0;
+}
+
+util.inherits(pbxWriter, EventEmitter);
+
+pbxWriter.prototype.write = function (str) {
+ var fmt = f.apply(null, arguments);
+
+ if (this.sync) {
+ this.buffer += f("%s%s", i(this.indentLevel), fmt);
+ } else {
+ // do stream write
+ }
+}
+
+pbxWriter.prototype.writeFlush = function (str) {
+ var oldIndent = this.indentLevel;
+
+ this.indentLevel = 0;
+
+ this.write.apply(this, arguments)
+
+ this.indentLevel = oldIndent;
+}
+
+pbxWriter.prototype.writeSync = function () {
+ this.sync = true;
+ this.buffer = "";
+
+ this.writeHeadComment();
+ this.writeProject();
+
+ return this.buffer;
+}
+
+pbxWriter.prototype.writeHeadComment = function () {
+ if (this.contents.headComment) {
+ this.write("// %s\n", this.contents.headComment)
+ }
+}
+
+pbxWriter.prototype.writeProject = function () {
+ var proj = this.contents.project,
+ key, cmt, obj;
+
+ this.write("{\n")
+
+ if (proj) {
+ this.indentLevel++;
+
+ for (key in proj) {
+ // skip comments
+ if (COMMENT_KEY.test(key)) continue;
+
+ cmt = comment(key, proj);
+ obj = proj[key];
+
+ if (isArray(obj)) {
+ this.writeArray(obj, key)
+ } else if (isObject(obj)) {
+ this.write("%s = {\n", key);
+ this.indentLevel++;
+
+ if (key === 'objects') {
+ this.writeObjectsSections(obj)
+ } else {
+ this.writeObject(obj)
+ }
+
+ this.indentLevel--;
+ this.write("};\n");
+ } else if (cmt) {
+ this.write("%s = %s /* %s */;\n", key, obj, cmt)
+ } else {
+ this.write("%s = %s;\n", key, obj)
+ }
+ }
+
+ this.indentLevel--;
+ }
+
+ this.write("}\n")
+}
+
+pbxWriter.prototype.writeObject = function (object) {
+ var key, obj, cmt;
+
+ for (key in object) {
+ if (COMMENT_KEY.test(key)) continue;
+
+ cmt = comment(key, object);
+ obj = object[key];
+
+ if (isArray(obj)) {
+ this.writeArray(obj, key)
+ } else if (isObject(obj)) {
+ this.write("%s = {\n", key);
+ this.indentLevel++;
+
+ this.writeObject(obj)
+
+ this.indentLevel--;
+ this.write("};\n");
+ } else {
+ if (cmt) {
+ this.write("%s = %s /* %s */;\n", key, obj, cmt)
+ } else {
+ this.write("%s = %s;\n", key, obj)
+ }
+ }
+ }
+}
+
+pbxWriter.prototype.writeObjectsSections = function (objects) {
+ var first = true,
+ key, obj;
+
+ for (key in objects) {
+ if (!first) {
+ this.writeFlush("\n")
+ } else {
+ first = false;
+ }
+
+ obj = objects[key];
+
+ if (isObject(obj)) {
+ this.writeSectionComment(key, true);
+
+ this.writeSection(obj);
+
+ this.writeSectionComment(key, false);
+ }
+ }
+}
+
+pbxWriter.prototype.writeArray = function (arr, name) {
+ var i, entry;
+
+ this.write("%s = (\n", name);
+ this.indentLevel++;
+
+ for (i=0; i < arr.length; i++) {
+ entry = arr[i]
+
+ if (entry.value && entry.comment) {
+ this.write('%s /* %s */,\n', entry.value, entry.comment);
+ } else if (isObject(entry)) {
+ this.write('{\n');
+ this.indentLevel++;
+
+ this.writeObject(entry);
+
+ this.indentLevel--;
+ this.write('},\n');
+ } else {
+ this.write('%s,\n', entry);
+ }
+ }
+
+ this.indentLevel--;
+ this.write(");\n");
+}
+
+pbxWriter.prototype.writeSectionComment = function (name, begin) {
+ if (begin) {
+ this.writeFlush("/* Begin %s section */\n", name)
+ } else { // end
+ this.writeFlush("/* End %s section */\n", name)
+ }
+}
+
+pbxWriter.prototype.writeSection = function (section) {
+ var key, obj, cmt;
+
+ // section should only contain objects
+ for (key in section) {
+ if (COMMENT_KEY.test(key)) continue;
+
+ cmt = comment(key, section);
+ obj = section[key]
+
+ if (obj.isa == 'PBXBuildFile' || obj.isa == 'PBXFileReference') {
+ this.writeInlineObject(key, cmt, obj);
+ } else {
+ if (cmt) {
+ this.write("%s /* %s */ = {\n", key, cmt);
+ } else {
+ this.write("%s = {\n", key);
+ }
+
+ this.indentLevel++
+
+ this.writeObject(obj)
+
+ this.indentLevel--
+ this.write("};\n");
+ }
+ }
+}
+
+pbxWriter.prototype.writeInlineObject = function (n, d, r) {
+ var output = [];
+
+ var inlineObjectHelper = function (name, desc, ref) {
+ var key, cmt, obj;
+
+ if (desc) {
+ output.push(f("%s /* %s */ = {", name, desc));
+ } else {
+ output.push(f("%s = {", name));
+ }
+
+ for (key in ref) {
+ if (COMMENT_KEY.test(key)) continue;
+
+ cmt = comment(key, ref);
+ obj = ref[key];
+
+ if (isArray(obj)) {
+ output.push(f("%s = (", key));
+
+ for (var i=0; i < obj.length; i++) {
+ output.push(f("%s, ", obj[i]))
+ }
+
+ output.push("); ");
+ } else if (isObject(obj)) {
+ inlineObjectHelper(key, cmt, obj)
+ } else if (cmt) {
+ output.push(f("%s = %s /* %s */; ", key, obj, cmt))
+ } else {
+ output.push(f("%s = %s; ", key, obj))
+ }
+ }
+
+ output.push("}; ");
+ }
+
+ inlineObjectHelper(n, d, r);
+
+ this.write("%s\n", output.join('').trim());
+}
+
+module.exports = pbxWriter;