Twitter: raymondcamden

Address: Lafayette, LA, USA

iOS Simulator not refreshing with Cordova (PhoneGap)? Read this.

06-20-2014 5,629 views Mobile 10 Comments

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


  • Shazron #
    Commented on 06-20-2014 at 1:15 PM
    Hopefully this will be baked in soon...
  • Shazron #
    Commented on 06-20-2014 at 1:17 PM
    You could do this in a before_emulate hook also, for now.
  • Commented on 06-20-2014 at 1:18 PM
    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.
  • Shazron #
    Commented on 06-20-2014 at 1:42 PM
    More info here:

    Add a hooks folder in your project root, and put the script there.
  • Commented on 06-20-2014 at 1:51 PM
    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.
  • Commented on 06-20-2014 at 1:55 PM
    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.
  • Shazron #
    Commented on 06-20-2014 at 1:57 PM
    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):
  • Goy J- #
    Commented on 06-27-2014 at 3:38 AM
    If I may troll a little: why Safari? This is simply the new IE6!
  • Commented on 06-27-2014 at 8:55 AM
    Only Safari can "talk" to the device like this. (Well, you can use other tools like Weinre too.)
  • Commented on 09-05-2014 at 2:10 PM
    For folks curious, the killall will also break GapDebug if you are using that for debugging.

Post Reply

Please refrain from posting large blocks of code as a comment. Use Pastebin or Gists instead. Text wrapped in asterisks (*) will be bold and text wrapped in underscores (_) will be italicized.

Leave this field empty