ionic cordova emulate - Cannot read property 'indexOf' of null
Description:
Command ionic cordova emulate ios without --address specified inserts
<allow-navigation href="http://:8100"/>
to config.xml which causes cordova emulate to fail. I have multiple network interfaces. Cannot read property 'indexOf' of null.
Steps to Reproduce:
With multiple network interfaces (cable + wifi connested for example) run ionic cordova emulate ios
Output: Cannot read property 'indexOf' of null.
My ionic info:
global packages:
@ionic/cli-utils : 1.4.0
Cordova CLI : 7.0.1
Ionic CLI : 3.4.0
local packages:
@ionic/app-scripts : 1.3.7
@ionic/cli-plugin-cordova : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms : ios 4.4.0
Ionic Framework : ionic-angular 3.3.0
System:
Node : v6.10.2
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
ios-sim : 5.0.13
npm : 3.10.10
Please run ionic cordova emulate ios --verbose and show us the output.
1. If I have two network interfaces active:
$ ionic cordova emulate ios --prod --target="iPad-Air-2" -lcs --verbose
[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
[WARN] Multiple network interfaces detected!
You will be prompted to select an external-facing IP for the livereload server that your device or emulator has
access to.
You may also use the --address option to skip this prompt.
[INFO] Starting app-scripts server: --livereload --l --consolelogs --c --serverlogs --s --prod --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser - Ctrl+C to cancel [10:42:16] watch started ... [10:42:16] build dev started ... [10:42:16] clean started ... [10:42:16] clean finished in 5 ms [10:42:16] copy started ... [10:42:16] transpile started ... [10:42:23] transpile finished in 6.94 s [10:42:23] preprocess started ... [10:42:23] deeplinks started ... [10:42:23] deeplinks finished in 393 ms [10:42:23] preprocess finished in 393 ms [10:42:23] webpack started ... [10:42:25] copy finished in 9.44 s [10:42:41] webpack finished in 17.64 s [10:42:41] sass started ... [10:42:43] sass finished in 1.62 s [10:42:43] postprocess started ... [10:42:43] postprocess finished in 6 ms [10:42:43] lint started ... [10:42:43] build dev finished in 26.68 s [10:42:43] watch ready in 26.84 s [10:42:43] dev server running: http://localhost:8100/
[INFO] Development server running Local: http://localhost:8100 External: http://:8100
cordova emulate ios --target iPad-Air-2 Error: Cannot read property 'indexOf' of null
[ERROR] Cordova encountered an error. You may get more insight by running the Cordova command above directly.
[DEBUG] !!! ERROR ENCOUNTERED !!! [ERROR] An error occurred while running cordova emulate ios --target iPad-Air-2 (exit code 1).
Martins-MacBook-Pro:src mka$ (node:26614) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: channel closed
2. This is probably another bug, but if I do not specify target, I get error as well:
$ ionic cordova emulate ios --address "10.240.104.43" --verbose
----------here is standard non failing cordova build output-----------
** BUILD SUCCEEDED **
Error: Cannot read property 'replace' of undefined
[ERROR] Cordova encountered an error. You may get more insight by running the Cordova command above directly.
[DEBUG] !!! ERROR ENCOUNTERED !!! [ERROR] An error occurred while running cordova emulate ios (exit code 1).
I can emulate just if I specify both target and address, othervise I get an error.
Ok, besides the bug in the 1) one that should be fixed by Ionic CLI the 2) one might actually be a problem with ios-sim, there was a pretty intense topic about that in the forum. Check a solution (and the whole topic) here: https://forum.ionicframework.com/t/error-cannot-read-property-replace-of-undefined-for-ios-sim/93663/19