About a month or two ago I noticed something odd with my Cordova tests. I'd fire off a call to the iOS simulator by doing cordova emulate ios
. The first time, it worked fine. But as I edited I noticed something odd. Subsequent calls to the emulator would end up in a blank screen in the emulator. If I watched carefully, I'd see my app load for a split second before going black.
Apparently, this is a bug with ios-sim, the command line tool used to talk to the simulator. If you know to check out the GitHub repo for it you will see a tip suggesting this command to fix it: killall launchd_sim
This works like a charm, and since I normally just "edit, alt-tab to terminal, click up, enter" in my dev cycle, I just switched my command to this: killall launchd_sim && cordova emulate ios
Archived Comments
Hopefully this will be baked in soon... https://issues.apache.org/j...
You could do this in a before_emulate hook also, for now.
Shaz, thanks for filing a bug for this. I thought there was one already.
Query - how do yo use before_emulate hooks? This is something I've never used before.
More info here: https://github.com/apache/c...
Add a hooks folder in your project root, and put the script there.
As a side note to folks (not related to Shaz's comments above):
I believe one side affect of this killall command is that Safari can't "see" the simulator anymore. What I mean is - when I use Safari Remote debugging and relaunch the app, the simulator is not available in the dropdown under Develop. If I kill Safari and restart it, it is available.
Shaz, any comment on that? If the Cordova CLI does add this in, that could be a possible negative side effect.
Shaz: Cool, the script works great and is less to type. It would be cool if the --copy-from command for making new projects also had a way to 'seed' hooks too.
Ouch. Never considered that. To add that into consideration we obviously can't do a killall, and find an alternative. Unfortunately it's an either or situation right now.
In better news, in Xcode 6 it appears ios-sim may finally be obsolete (who knows for sure yet):
https://github.com/phonegap...
If I may troll a little: why Safari? This is simply the new IE6!
Only Safari can "talk" to the device like this. (Well, you can use other tools like Weinre too.)
For folks curious, the killall will also break GapDebug if you are using that for debugging.