Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cordova run does not work #486

Closed
knight9999 opened this issue Dec 23, 2018 · 8 comments
Closed

Cordova run does not work #486

knight9999 opened this issue Dec 23, 2018 · 8 comments

Comments

@knight9999
Copy link
Contributor

knight9999 commented Dec 23, 2018

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)
@dpogue
Copy link
Member

dpogue commented Dec 23, 2018

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.

If you're codesigning with automatic provisioning, you must create an archive and then export it 😞
However, maybe we only need to care about that for builds with --release?

@knight9999
Copy link
Contributor Author

knight9999 commented Dec 23, 2018

Thanks for the comment @dpogue .

To get the .ipa file, as you mentioned, I must create an archive and then export it.

On the other hand, ios-deploy needs .app package, not the .ipa file.

I can get .app package by unzipping .ipa file (.app package can be found in Payload directory) as cordova/lib/run.js.
But ios-deploy does not work with this .app pacakge when we use xcode 10's xcodebuild. (This works if we build the app by using xcode 9's xcodebuild.)
Therefore I use xcodebuild build command to get .app package directly.
Then ios-deploy works with the .app package.
I have checked on both xcode 9 and xcode 10.

Now I care about all --emulator --debug, --device --debug and --device --release.
(BTH --emulator --debug in some environment does not work.
In such case, we should specify the appropriate --target.
This is because that the default emulator inlist-emulator-build-targets is different from the
default emulator In list-emulator-images. I will create another issue about this. )

@brodycj
Copy link

brodycj commented Dec 24, 2018

It looks to me like you applied a workaround to the issue with shell.rm in PR #487. I hope we can migrate from shelljs to fs-extra in the near future, in a separate PR.

@knight9999
Copy link
Contributor Author

Thanks for the comment @brodybits .

knight9999 pushed a commit to knight9999/cordova-ios that referenced this issue Dec 25, 2018
…ive according to cordova run and cordova build respectively
@shazron
Copy link
Member

shazron commented Jan 9, 2019

I just discovered this same issue in #488 (comment) (but I just used fs.unlinkSync)

@shazron
Copy link
Member

shazron commented Jan 9, 2019

The related ios-deploy issue: ios-control/ios-deploy#364

@shazron
Copy link
Member

shazron commented Jan 10, 2019

The ios-deploy issue is a false alarm -- it needed the flag --buildFlag='-UseModernBuildSystem=0'

@knight9999
Copy link
Contributor Author

knight9999 commented Jan 11, 2019

@shazron Thanks. As you said, --buildFlad='-UseModernBuildSystem=0' works.
However I want to solve the issue with this flags.

This issue is solved by your other PR #494
where manual provisioning is used to extract archives and cordova run command (i.e. ios-deploy) works well.
Therefore I will close this issue if there are any other comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants