Blank screen in iOS App - unexpected token '<'

The screen is blank when the app loads no matter if I delete cordova-build, build, plugin-cache from the .meteor/local directory.

When I attach to the simulator process using Safari Developer and do a CMD-R (Reload) I get the following JS error in the console: SyntaxError: Unexpected token ‘<’ cordova_plugin.js:1.

If I look at cordova_plugins.js its HTML, not JS.

Sometimes after scrubbing everything and forcing a couple reloads the app will load, but as soon as I have a hot code reload its back to the same error.

Anyone else seeing this?

Haven’t seen this issue before. But you may try if this package helps: https://atmospherejs.com/percolate/safe-reload

It happens quite often that a hot code reload breaks the whole app beyond recovery. The only solution in this case is to re-install it. Martijn is working on this and promised a better solution for Meteor 1.3.

BTW: I am already using the safe-reload package @daveeel mentioned, but unfortunately this did not really help much. These broken apps are really a PITA, and I hope 1.3 comes out before I go live with my app. :-/

Do you have a recommend procedure for getting them working again? Deleting the app from the simulator, scrubbing files from .meteor/local and rebuilding, doesn’t always result in a working app for me.

Typically, the problem goes away if I delete the app and re-deploy it on the device. A big problem is, however, that even in this case the app will be hot reloading at least once (I never found out why this happens; I would expect that the app would be deployed in its latest version, but this is obviously not the case). Fortunately, it only happens once in a while that this initial hot code reload breaks the app again. If his happens, the safest way to re-install everything is to do a meteor reset. But in this case, you not only lose your whole dev database, but Meteor also re-downloads all Cordova plugins. Which in my case literally takes ages.

Thanks for the help. I was trying to avoid the meteor reset, but will give that a try.

This is an exploration effort for me. I have an existing native iOS app. Maybe I’ll look at just adding the DDPObjective CocoaPod to it.

Always doing an initial hot code push was a bug that has been fixed for 1.3: https://github.com/meteor/meteor/commit/2bacce618cd9b9c2b274e1b4ca207be8403b6efd

Thanks for that info.

One question about this: I noticed that the app version that is being hot-code-pushed on startup differs from the app version that shows up on initial startup (i.e. before the HCP). Is this also fixed in 1.3, i.e. do you always get the most recent app version now if you just start the app on the device?

That is what this bug fix is about: the version numbers would differ, even though there had not been changes.

Are you sure there are no changes? In my experience, the app that is started right away does not reflect the latest state. It seems as if it rather reflects the last time I did a “meteor reset”. Only after the initial HCR I am getting the correct version.

Ah, there is another hot code push issue (again, solved in the rewrite) that you may have run into: an app will always startup with the last downloaded version, even if the bundled version has changed. So basically the bundled version will always be ignored after the first install.

Thanks for this additional info. Highly appreciated. I’m really glad you’re working on this - and can’t wait to get the update :slight_smile:

Thanks for all the help. I’ll checkout the 1.3 branch and see if it cures all my woes.

@martijnwalraven I just noticed that you are the author of the meteor-ios (https://github.com/martijnwalraven/meteor-ios) library. I just started looking at that as a separate approach to integrating an existing iOS app. Are you actively using this in your projects? or are you using cordova mobile clients? I guess it all depends.

I’m not actively using Meteor iOS in my own projects, but then I don’t currently have any projects :slight_smile: When I started working for MDG, it made more sense to focus on improving the Cordova integration first. But I definitely think there is a place for native apps with Meteor, especially if you have existing code.

Another promising direction is React Native. We don’t have a good story for that right now, but some of the work in Meteor 1.3 and beyond should help us get there.

Was digging deeper on my initial problem. Just finished this thread that @martijnwalraven commented on - https://github.com/meteor/meteor/issues/4038#issuecomment-171003647. I’m definitely having the problem that simap refers to (https://github.com/meteor/meteor/issues/4038#issuecomment-170736556). “If somehow an update goes sideways and a file is missing but the update continues, missing files will be replaced with the index file.” Even after resetting the simulator, clearing my xcode cache, resetting meteor, etc I still have missing files that get filled with index.html. Will try turning off the hot code push and see if I can get pass this.

Even with a clean device and a meteor reset I cannot get meteor to build and load a proper Cordova target. I always see this:
METEOR CORDOVA DEBUG loading filepath: /Users/matt/Library/Developer/CoreSimulator/Devices/BC84899F-2A14-4A62-BF94-C082BF98D64C/data/Containers/Bundle/Application/0E29DA3E-E854-4B02-82F6-605469C1584A/Reflector.app/www/application/index.html for path: %2Fapp%2Fclient%2Fcordova_plugins.js

It always loads index.html for the cordova_plugins.js path.