Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic emulate ios only works with --livereload

I have a simple ionic app that I'm building and when I test with ionic serve --lab, everything looks great, however, when I try to emulate on the simulators with ionic emulate ios or ionic emulate android, the app doesn't load (seems like all the JS isn't coming through). I am able to attach the debugger and there aren't any console errors.

But, when I do try and run the app with ionic emulate ios --livereload everything seems to work fine.

I tried another sample app from scratch to rule out my machine env and it worked fine.

Any ideas on how I can get the emulate to work without --livereload?

like image 824
Steve Sloka Avatar asked Apr 30 '15 18:04

Steve Sloka


People also ask

How do I run an ionic app on iOS emulator?

Safari has Web Inspector support for iOS simulators and devices. Open the Develop menu and select the simulator or device, then select the Ionic App to open Web Inspector.

Does ionic support iOS?

Because of this foundation in web technologies, Ionic can run anywhere the web runs — iOS, Android, browsers, PWAs, and more.

Does ionic support hot reload?

We can use the Ionic CLI's Live Reload functionality to boost our productivity when building Ionic apps. When active, Live Reload will reload the browser and/or WebView when changes in the app are detected.


2 Answers

I had the same issue today. I resolved it by removing certain angular dependencies that weren't being detected by the ios build. Check your jslint for any warnings that may provide more information about which dependencies may be injected incorrectly or missing.

See this comment on the Ionic forums for further info.

like image 184
Ricky Avatar answered Sep 23 '22 08:09

Ricky


In my case the white screen of death was caused by bad references to bower components.

For our build process, the relative location of bower components is different is the "source" compared to when the app has been packaged to "www" (bower components are copied to the root directory).

The following reference works when the app is served (if you hover over the links in Chrome inspector, the ".." is removed), but don't work when launched on a device/emulator:

<script src="../bower_components/angular/angular.js"></script>

Live reload works because the application is not being served from the device's file system. Instead Ionic is serving it from the host machine and presumably the bad relative path ("..") is silently ignored as it is when tested in the browser.

Fixing the paths as follows resolved in the problem:

<script src="bower_components/angular/angular.js"></script>

The outstanding question is why no apparent errors are thrown by any component of the application.

like image 31
Joel Skrepnek Avatar answered Sep 24 '22 08:09

Joel Skrepnek