You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/08/20 16:54:43 UTC
[1/2] git commit: CB-7118 iOS: add target-device and MinimumOSVersion
support to config.xml
Repository: cordova-lib
Updated Branches:
refs/heads/master 884852fa7 -> c86cd7271
CB-7118 iOS: add target-device and MinimumOSVersion support to config.xml
github: close #57
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/b9eca985
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/b9eca985
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/b9eca985
Branch: refs/heads/master
Commit: b9eca9851ead2df69021ce83fbf728d78774c1bd
Parents: 884852f
Author: sgrebnov <v-...@microsoft.com>
Authored: Fri Jul 11 09:44:50 2014 +0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Aug 20 10:46:22 2014 -0400
----------------------------------------------------------------------
cordova-lib/src/cordova/metadata/ios_parser.js | 71 +++++++++++++++++++--
1 file changed, 64 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b9eca985/cordova-lib/src/cordova/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/ios_parser.js b/cordova-lib/src/cordova/metadata/ios_parser.js
index a6254ac..f43f194 100644
--- a/cordova-lib/src/cordova/metadata/ios_parser.js
+++ b/cordova-lib/src/cordova/metadata/ios_parser.js
@@ -134,11 +134,17 @@ module.exports.prototype = {
shell.cp('-f', src, dest);
}
});
+
+ var me = this;
+ return this.update_build_settings(config).then(function() {
+ if (name == me.originalName) {
+ events.emit('verbose', 'iOS Product Name has not changed (still "' + me.originalName + '")');
+ return Q();
+ }
- if (name != this.originalName) {
// Update product name inside pbxproj file
- var proj = new xcode.project(this.pbxproj);
- var parser = this;
+ var proj = new xcode.project(me.pbxproj);
+ var parser = me;
var d = Q.defer();
proj.parse(function(err,hash) {
if (err) {
@@ -163,10 +169,7 @@ module.exports.prototype = {
}
});
return d.promise;
- } else {
- events.emit('verbose', 'iOS Product Name has not changed (still "' + this.originalName + '")');
- return Q();
- }
+ });
},
// Returns the platform-specific www directory.
@@ -217,6 +220,38 @@ module.exports.prototype = {
self.update_overrides();
util.deleteSvnFolders(self.www_dir());
});
+ },
+
+ update_build_settings:function(config) {
+ var targetDevice = parseTargetDevicePreference(config.getPreference('target-device', 'ios'));
+ var deploymentTarget = config.getPreference('deployment-target', 'ios');
+
+ // no build settings provided, we don't need to parse and update .pbxproj file
+ if (!targetDevice && !deploymentTarget) {
+ return Q();
+ }
+
+ var me = this;
+ var d = Q.defer();
+ var proj = new xcode.project(this.pbxproj);
+ proj.parse(function(err,hash) {
+ if (err) {
+ d.reject(new Error('An error occured during parsing of project.pbxproj. Start weeping. Output: ' + err));
+ return;
+ }
+ var buildConfiguration = proj.pbxXCBuildConfigurationSection();
+ if (targetDevice) {
+ // TODO: replace propReplace with proj.updateBuildProperty after below is release
+ // https://github.com/alunny/node-xcode/pull/33
+ propReplace(buildConfiguration, 'TARGETED_DEVICE_FAMILY', targetDevice);
+ }
+ if (deploymentTarget) {
+ propReplace(buildConfiguration, 'IPHONEOS_DEPLOYMENT_TARGET', deploymentTarget);
+ }
+ fs.writeFileSync(me.pbxproj, proj.writeSync(), 'utf-8');
+ d.resolve();
+ });
+ return d.promise;
}
};
@@ -226,3 +261,25 @@ module.exports.prototype = {
function default_CFBundleVersion(version) {
return version.split('-')[0];
}
+// Converts cordova specific representation of target device to XCode value
+function parseTargetDevicePreference(value) {
+ if (!value) return null;
+ var map = { 'universal': '"1,2"', 'handset': '"1"', 'tablet': '"2"'}
+ if (map[value.toLowerCase()]) {
+ return map[value.toLowerCase()]
+ }
+ events.emit('warn', 'Unknown target-device preference value: "' + value + '".');
+ return null;
+}
+// helper recursive prop search+replace
+function propReplace(obj, prop, value) {
+ for (var p in obj) {
+ if (obj.hasOwnProperty(p)) {
+ if (typeof obj[p] == 'object') {
+ propReplace(obj[p], prop, value);
+ } else if (p == prop) {
+ obj[p] = value;
+ }
+ }
+ }
+}
[2/2] git commit: CB-7118 Use updated version of node-xcode
Posted by ag...@apache.org.
CB-7118 Use updated version of node-xcode
Conflicts:
cordova-lib/src/cordova/metadata/ios_parser.js
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/c86cd727
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/c86cd727
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/c86cd727
Branch: refs/heads/master
Commit: c86cd7271bbfa73d7db3382de1f2a200884b3bbc
Parents: b9eca98
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Aug 20 10:49:05 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Aug 20 10:49:05 2014 -0400
----------------------------------------------------------------------
cordova-lib/package.json | 2 +-
cordova-lib/src/cordova/metadata/ios_parser.js | 22 +++++----------------
2 files changed, 6 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/c86cd727/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 6bffa4d..1d8ab81 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -34,7 +34,7 @@
"shelljs": "0.1.x",
"tar": "0.1.x",
"underscore": "1.4.4",
- "xcode": "0.6.6",
+ "xcode": "0.6.7",
"cordova-js": "3.x.x",
"unorm": ">=1.3"
},
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/c86cd727/cordova-lib/src/cordova/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/ios_parser.js b/cordova-lib/src/cordova/metadata/ios_parser.js
index f43f194..19b63e8 100644
--- a/cordova-lib/src/cordova/metadata/ios_parser.js
+++ b/cordova-lib/src/cordova/metadata/ios_parser.js
@@ -239,14 +239,13 @@ module.exports.prototype = {
d.reject(new Error('An error occured during parsing of project.pbxproj. Start weeping. Output: ' + err));
return;
}
- var buildConfiguration = proj.pbxXCBuildConfigurationSection();
if (targetDevice) {
- // TODO: replace propReplace with proj.updateBuildProperty after below is release
- // https://github.com/alunny/node-xcode/pull/33
- propReplace(buildConfiguration, 'TARGETED_DEVICE_FAMILY', targetDevice);
+ events.emit('verbose', 'Set TARGETED_DEVICE_FAMILY to ' + targetDevice + '.');
+ proj.updateBuildProperty('TARGETED_DEVICE_FAMILY', targetDevice);
}
if (deploymentTarget) {
- propReplace(buildConfiguration, 'IPHONEOS_DEPLOYMENT_TARGET', deploymentTarget);
+ events.emit('verbose', 'Set IPHONEOS_DEPLOYMENT_TARGET to "' + deploymentTarget + '".');
+ proj.updateBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', deploymentTarget);
}
fs.writeFileSync(me.pbxproj, proj.writeSync(), 'utf-8');
d.resolve();
@@ -261,6 +260,7 @@ module.exports.prototype = {
function default_CFBundleVersion(version) {
return version.split('-')[0];
}
+
// Converts cordova specific representation of target device to XCode value
function parseTargetDevicePreference(value) {
if (!value) return null;
@@ -271,15 +271,3 @@ function parseTargetDevicePreference(value) {
events.emit('warn', 'Unknown target-device preference value: "' + value + '".');
return null;
}
-// helper recursive prop search+replace
-function propReplace(obj, prop, value) {
- for (var p in obj) {
- if (obj.hasOwnProperty(p)) {
- if (typeof obj[p] == 'object') {
- propReplace(obj[p], prop, value);
- } else if (p == prop) {
- obj[p] = value;
- }
- }
- }
-}