You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/01/11 01:11:49 UTC

[GitHub] knight9999 closed pull request #487: Fix issue #486. Distinguish xcodebuild `build` command and `archive` command.

knight9999 closed pull request #487: Fix issue #486. Distinguish xcodebuild `build` command and `archive` command.
URL: https://github.com/apache/cordova-ios/pull/487
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js
index 80a611171..c58367c1a 100644
--- a/bin/templates/scripts/cordova/lib/build.js
+++ b/bin/templates/scripts/cordova/lib/build.js
@@ -170,7 +170,7 @@ module.exports.run = function (buildOpts) {
             // remove the build/device folder before building
             shell.rm('-rf', buildOutputDir);
 
-            var xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, buildOpts.device, buildOpts.buildFlag, emulatorTarget, buildOpts.automaticProvisioning);
+            var xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, buildOpts.device, buildOpts.buildFlag, emulatorTarget, buildOpts.automaticProvisioning, buildOpts.buildAction);
             return superspawn.spawn('xcodebuild', xcodebuildArgs, { cwd: projectPath, printCommand: true, stdio: 'inherit' });
 
         }).then(function () {
@@ -269,7 +269,7 @@ module.exports.findXCodeProjectIn = findXCodeProjectIn;
  * @param  {Boolean} autoProvisioning   Whether to allow Xcode to automatically update provisioning
  * @return {Array}                  Array of arguments that could be passed directly to spawn method
  */
-function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, buildFlags, emulatorTarget, autoProvisioning) {
+function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, buildFlags, emulatorTarget, autoProvisioning, buildAction) {
     var xcodebuildArgs;
     var options;
     var buildActions;
@@ -295,7 +295,7 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b
             '-destination', customArgs.destination || 'generic/platform=iOS',
             '-archivePath', customArgs.archivePath || projectName + '.xcarchive'
         ];
-        buildActions = [ 'archive' ];
+        buildActions = buildAction ? [ buildAction ] : [ 'archive' ];
         settings = [
             customArgs.configuration_build_dir || 'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'device'),
             customArgs.shared_precomps_dir || 'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
diff --git a/bin/templates/scripts/cordova/lib/run.js b/bin/templates/scripts/cordova/lib/run.js
index a51882e1f..4c62ccdcc 100644
--- a/bin/templates/scripts/cordova/lib/run.js
+++ b/bin/templates/scripts/cordova/lib/run.js
@@ -21,7 +21,6 @@ var Q = require('q');
 var path = require('path');
 var cp = require('child_process');
 var build = require('./build');
-var shell = require('shelljs');
 var superspawn = require('cordova-common').superspawn;
 var check_reqs = require('./check_reqs');
 
@@ -59,6 +58,13 @@ module.exports.run = function (runOptions) {
                 return check_reqs.check_ios_deploy();
             }
         }).then(function () {
+            if (useDevice) { // for device
+                if (!runOptions['nobuild-device']) {
+                    return build.run(Object.assign({}, runOptions, {buildFlag: 'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'device-run'), buildAction: 'build'}));
+                } else {
+                    return Q.resolve();
+                }
+            } // for emulator
             if (!runOptions.nobuild) {
                 return build.run(runOptions);
             } else {
@@ -68,36 +74,10 @@ module.exports.run = function (runOptions) {
             return build.findXCodeProjectIn(projectPath);
         }).then(function (projectName) {
             var appPath = path.join(projectPath, 'build', 'emulator', projectName + '.app');
-            var buildOutputDir = path.join(projectPath, 'build', 'device');
-
-            // select command to run and arguments depending whether
-            // we're running on device/emulator
             if (useDevice) {
                 return module.exports.checkDeviceConnected()
                     .then(function () {
-                        // Unpack IPA
-                        var ipafile = path.join(buildOutputDir, projectName + '.ipa');
-
-                        // unpack the existing platform/ios/build/device/appname.ipa (zipfile), will create a Payload folder
-                        return superspawn.spawn('unzip', [ '-o', '-qq', ipafile ], { cwd: buildOutputDir, printCommand: true, stdio: 'inherit' });
-                    })
-                    .then(function () {
-                        // Uncompress IPA (zip file)
-                        var appFileInflated = path.join(buildOutputDir, 'Payload', projectName + '.app');
-                        var appFile = path.join(buildOutputDir, projectName + '.app');
-                        var payloadFolder = path.join(buildOutputDir, 'Payload');
-
-                        // delete the existing platform/ios/build/device/appname.app
-                        shell.rm('-rf', appFile);
-                        // move the platform/ios/build/device/Payload/appname.app to parent
-                        shell.mv('-f', appFileInflated, buildOutputDir);
-                        // delete the platform/ios/build/device/Payload folder
-                        shell.rm('-rf', payloadFolder);
-
-                        return null;
-                    })
-                    .then(function () {
-                        appPath = path.join(projectPath, 'build', 'device', projectName + '.app');
+                        appPath = path.join(projectPath, 'build', 'device-run', projectName + '.app');
                         var extraArgs = [];
                         if (runOptions.argv) {
                             // argv.slice(2) removes node and run.js, filterSupportedArgs removes the run.js args
@@ -129,7 +109,7 @@ module.exports.listEmulators = listEmulators;
  */
 function filterSupportedArgs (args) {
     var filtered = [];
-    var sargs = ['--device', '--emulator', '--nobuild', '--list', '--target', '--debug', '--release'];
+    var sargs = ['--device', '--emulator', '--nobuild', '--nobuild-device', '--list', '--target', '--debug', '--release'];
     var re = new RegExp(sargs.join('|'));
 
     args.forEach(function (element) {
@@ -228,7 +208,7 @@ function listEmulators () {
 }
 
 module.exports.help = function () {
-    console.log('\nUsage: run [ --device | [ --emulator [ --target=<id> ] ] ] [ --debug | --release | --nobuild ]');
+    console.log('\nUsage: run [ --device | [ --emulator [ --target=<id> ] ] ] [ --debug | --release | --nobuild | --nobuild-device ]');
     // TODO: add support for building different archs
     // console.log("           [ --archs=\"<list of target architectures>\" ] ");
     console.log('    --device      : Deploys and runs the project on the connected device.');
@@ -236,7 +216,8 @@ module.exports.help = function () {
     console.log('    --target=<id> : Deploys and runs the project on the specified target.');
     console.log('    --debug       : Builds project in debug mode. (Passed down to build command, if necessary)');
     console.log('    --release     : Builds project in release mode. (Passed down to build command, if necessary)');
-    console.log('    --nobuild     : Uses pre-built package, or errors if project is not built.');
+    console.log('    --nobuild     : Uses pre-built package, or errors if project is not built for emulator.');
+    console.log('    --nobuild-device : Uses pre-built package, or errors if project is not built for device.');
     // TODO: add support for building different archs
     // console.log("    --archs       : Specific chip architectures (`anycpu`, `arm`, `x86`, `x64`).");
     console.log('');


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org