Skip to content

Cordova run does not work #486

Closed
Closed
@knight9999

Description

@knight9999

When doing cordova run, the following errors happened.

Running command: unzip -o -qq /Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/platforms/ios/build/device/HelloCordova.ipa
shell.js: internal error
Error: ENOTDIR: not a directory, rename '/Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/platforms/ios/build/device/Payload/HelloCordova.app' -> '/Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/platforms/ios/build/device/HelloCordova.app'
    at Object.fs.renameSync (fs.js:734:3)
    at /Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/node_modules/shelljs/src/mv.js:77:8
    at Array.forEach (<anonymous>)
    at Object._mv (/Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/node_modules/shelljs/src/mv.js:53:11)
    at Object.mv (/Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/node_modules/shelljs/src/common.js:186:23)
    at /Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/platforms/ios/cordova/lib/run.js:93:31
    at _fulfilled (/Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/node_modules/q/q.js:854:54)
    at /Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/node_modules/q/q.js:816:13)
    at /Users/knaito/Documents/work/cordova-develop/coho/xcode10Test/node_modules/q/q.js:624:44

shelljs.rm introduced by the commit/4694547bcc360c4c68331285593e69aae7232752 can not remove symbolic link Application.app (HelloCordova.app in this case) due to the specification of shelljs itself. Therefore cordova/lib/run.js can not remove the symbolic link Application.app (HelloCordova.app) in cordova/build/device (or cordova/build/emulator) and the errors happen.

If we modify

shell.rm('-rf', appFile);

by

fs = require('fs-extra');
fs.removeSync(appFile);

in cordova/ib/run.js, cordova run works successfully with xcode 9.

However, with xcode 10, there is another issue.
cordova run --device can install the application to the device, but the installed application does not start normally. The following error happen.

(lldb)     command script import "/tmp/EAFFDD68-8CFA-4EB7-9229-5FD1AF98C3CA/fruitstrap_ba44e73fdb9b30f4616b14d471c77063e11f583d.py"
(lldb)     command script add -f fruitstrap_ba44e73fdb9b30f4616b14d471c77063e11f583d.connect_command connect
(lldb)     command script add -s asynchronous -f fruitstrap_ba44e73fdb9b30f4616b14d471c77063e11f583d.run_command run
(lldb)     command script add -s asynchronous -f fruitstrap_ba44e73fdb9b30f4616b14d471c77063e11f583d.autoexit_command autoexit
(lldb)     command script add -s asynchronous -f fruitstrap_ba44e73fdb9b30f4616b14d471c77063e11f583d.safequit_command safequit
(lldb)     connect
(lldb)     run
error: process launch failed: failed to get the task for process 53287
(lldb)     safequit

Application has not been launched

ios-deploy: Command failed with exit code 1

This is more serious issue.

WIth Xcode 10, we should use xcodebuild build command for this sake (cordova run, i.e. ios-deploy).

However, cordova/ios/build.js uses xcodebuild archive command and xcodebuild -exportArchive command to extract .ipa file from the archive, and then cordova/ios/run.js unzips .ipa file to get a pacakge Application.app(Here HelloCordova.app). This works with xcode 9, but this looks not working with xcode 10.

I beleive that with Xcode 10 we should use xcodebuild build command to get Application.app (HelloCordova.app) package instead of combination of using xcodebuild archive, xcodebuild -exportArchive and unzip .ipa file.


How to reproduce 1st error:

$ npx cordova@nightly create xcode10Test com.foo.bar
$ cd ./xcode10Test
$ npx cordova@nightly platform add github:apache/cordova-ios
$ vi build.json
$ npx cordova@nightly run ios --device --release
(or $ npx cordova@nightly run ios --device --debug)

How to reproduce 2nd error:

select xcode 10 by xcode-select command,
then

$ npx cordova@nightly create xcode10Test com.foo.bar
$ cd ./xcode10Test
$ npx cordova@nightly platform add github:apache/cordova-ios
$ vi build.json

modify the code

shell.rm('-rf', appFile);

(about at line 93) in platforms/ios/lib/run.js by

fs = require('fs-extra');
fs.removeSync(appFile);

then

$ npx cordova@nightly run ios --device --release
(or $ npx cordova@nightly run ios --device --debug)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions