You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2016/10/04 22:54:25 UTC
[3/4] ios commit: CB-11860 - Update packaging strategy for Xcode 8
CB-11860 - Update packaging strategy for Xcode 8
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/249db303
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/249db303
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/249db303
Branch: refs/heads/master
Commit: 249db303e258237479cd16b94c1349f2be65978b
Parents: c6587cf
Author: Darryl Pogue <da...@ayogo.com>
Authored: Thu Sep 15 16:58:21 2016 -0700
Committer: Darryl Pogue <da...@ayogo.com>
Committed: Fri Sep 30 17:33:16 2016 -0700
----------------------------------------------------------------------
bin/templates/scripts/cordova/build | 1 +
bin/templates/scripts/cordova/lib/build.js | 63 ++++++++++++++++++-------
2 files changed, 48 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/249db303/bin/templates/scripts/cordova/build
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/build b/bin/templates/scripts/cordova/build
index f5b7935..133fd94 100755
--- a/bin/templates/scripts/cordova/build
+++ b/bin/templates/scripts/cordova/build
@@ -43,6 +43,7 @@ var buildOpts = nopt({
'codeSignResourceRules': String,
'provisioningProfile': String,
'developmentTeam': String,
+ 'packageType': String,
'buildConfig' : String,
'noSign' : Boolean
}, { '-r': '--release', 'd' : '--verbose' }, args);
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/249db303/bin/templates/scripts/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js
index a0d7668..ee03891 100644
--- a/bin/templates/scripts/cordova/lib/build.js
+++ b/bin/templates/scripts/cordova/lib/build.js
@@ -24,7 +24,8 @@ var Q = require('q'),
shell = require('shelljs'),
spawn = require('./spawn'),
check_reqs = require('./check_reqs'),
- fs = require('fs');
+ fs = require('fs'),
+ plist = require('plist');
var events = require('cordova-common').events;
@@ -54,7 +55,7 @@ module.exports.run = function (buildOpts) {
var buildType = buildOpts.release ? 'release' : 'debug';
var config = buildConfig.ios[buildType];
if(config) {
- ['codeSignIdentity', 'codeSignResourceRules', 'provisioningProfile', 'developmentTeam'].forEach(
+ ['codeSignIdentity', 'codeSignResourceRules', 'provisioningProfile', 'developmentTeam', 'packageType'].forEach(
function(key) {
buildOpts[key] = buildOpts[key] || config[key];
});
@@ -88,25 +89,35 @@ module.exports.run = function (buildOpts) {
events.emit('log','\tConfiguration: ' + configuration);
events.emit('log','\tPlatform: ' + (buildOpts.device ? 'device' : 'emulator'));
- var xcodebuildArgs = getXcodeArgs(projectName, projectPath, configuration, buildOpts.device);
+ var xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, buildOpts.device);
return spawn('xcodebuild', xcodebuildArgs, projectPath);
}).then(function () {
if (!buildOpts.device || buildOpts.noSign) {
return;
}
- var buildOutputDir = path.join(projectPath, 'build', 'device');
- var pathToApp = path.join(buildOutputDir, projectName + '.app');
- var pathToIpa = path.join(buildOutputDir, projectName + '.ipa');
- var xcRunArgs = ['-sdk', 'iphoneos', 'PackageApplication',
- pathToApp,
- '-o', pathToIpa];
- if (buildOpts.codeSignIdentity) {
- xcRunArgs.concat('--sign', buildOpts.codeSignIdentity);
+
+ var exportOptions = {'compileBitcode': false, 'method': 'development'};
+
+ if (buildOpts.packageType) {
+ exportOptions.method = buildOpts.packageType;
}
- if (buildOpts.provisioningProfile) {
- xcRunArgs.concat('--embed', buildOpts.provisioningProfile);
+
+ if (buildOpts.developmentTeam) {
+ exportOptions.teamID = buildOpts.developmentTeam;
}
- return spawn('xcrun', xcRunArgs, projectPath);
+
+ var exportOptionsPlist = plist.build(exportOptions);
+ var exportOptionsPath = path.join(projectPath, 'exportOptions.plist');
+
+ var buildOutputDir = path.join(projectPath, 'build', 'device');
+
+ function packageArchive() {
+ var xcodearchiveArgs = getXcodeArchiveArgs(projectName, projectPath, buildOutputDir, exportOptionsPath);
+ return spawn('xcodebuild', xcodearchiveArgs, projectPath);
+ }
+
+ return Q.nfcall(fs.writeFile, exportOptionsPath, exportOptionsPlist, 'utf-8')
+ .then(packageArchive);
});
};
@@ -143,7 +154,7 @@ module.exports.findXCodeProjectIn = findXCodeProjectIn;
* @param {Boolean} isDevice Flag that specify target for package (device/emulator)
* @return {Array} Array of arguments that could be passed directly to spawn method
*/
-function getXcodeArgs(projectName, projectPath, configuration, isDevice) {
+function getXcodeBuildArgs(projectName, projectPath, configuration, isDevice) {
var xcodebuildArgs;
if (isDevice) {
xcodebuildArgs = [
@@ -152,7 +163,8 @@ function getXcodeArgs(projectName, projectPath, configuration, isDevice) {
'-scheme', projectName,
'-configuration', configuration,
'-destination', 'generic/platform=iOS',
- 'build',
+ '-archivePath', projectName + '.xcarchive',
+ 'archive',
'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'device'),
'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
];
@@ -172,6 +184,25 @@ function getXcodeArgs(projectName, projectPath, configuration, isDevice) {
return xcodebuildArgs;
}
+
+/**
+ * Returns array of arguments for xcodebuild
+ * @param {String} projectName Name of xcode project
+ * @param {String} projectPath Path to project file. Will be used to set CWD for xcodebuild
+ * @param {String} outputPath Output directory to contain the IPA
+ * @param {String} exportOptionsPath Path to the exportOptions.plist file
+ * @return {Array} Array of arguments that could be passed directly to spawn method
+ */
+function getXcodeArchiveArgs(projectName, projectPath, outputPath, exportOptionsPath) {
+ return [
+ '-exportArchive',
+ '-archivePath', projectName + '.xcarchive',
+ '-exportOptionsPlist', exportOptionsPath,
+ '-exportPath', outputPath
+ ];
+}
+
+
// help/usage function
module.exports.help = function help() {
console.log('');
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org