Shazron's Cordova (aka PhoneGap) Blog

at Adobe Systems Inc.

Running your iPhone app in the Simulator without Xcode (with log support)

with 9 comments

I started writing this shell script because Xcode 4 keeps crashing, so I ended up editing my code in TextMate, and had iTerm open so I can build, then deploy the app automatically in iPhone Simulator.

The script takes three arguments, the first is the name of the project (here the limitation is that it has to be the name of the .xcodeproj and the .app name), and the second is the configuration (Debug/Release – defaults to Debug), and the third is an optional argument, the name of the log file that the log will be written to (defaults to stderror.log).

Also, you will need the latest code of ios-sim. I could have added a step to check whether you have it installed and download, build and install it for you, but maybe next time đŸ˜‰ Make sure you download the latest source, and not one of the packages.

One you download it and build it, copy the ios-sim binary to somewhere in your path – /usr/bin is a good location.

Download the script. It is WTFPL licensed. Run it without arguments to see the help text.

Run chmod 755 sim-run.sh on the script to give it exec privileges.

The script builds your project, launches the project in the iPhone Simulator, activates the iPhone Simulator (brings it to front), logs the output to a file, and also displays the contents of the logfile as it is written to. On each run, it writes to a fresh log file, and the previous log file is backed up.

Written by shazron

February 23, 2011 at 10:16 pm

Posted in xcode

9 Responses

Subscribe to comments with RSS.

  1. Awesome! I had to remove the –exit argument to get it to work with the latest ios-sim

    Greg

    February 27, 2011 at 8:22 pm

  2. Nevermind, I was using version 1.1 of ios-sim. After cloning from git, I was able to put the –exit back in

    Greg

    February 27, 2011 at 8:25 pm

  3. Good to hear Greg đŸ™‚ I did mention “Make sure you download the latest source, and not one of the packages”.

    You don’t need to clone from git, when you click on the “Downloads” button from Github, there is a “Download .zip” button, click on that instead of the tagged 1.0 and 1.1

    shazron

    February 28, 2011 at 12:21 am

  4. Do you know if there is a way to use a script to get the code on a device?

    Thanks

    Greg

    March 3, 2011 at 4:00 pm

  5. None that I know of yet – although it is possible through AppleScript, but not ideal because it does launch the GUI http://stackoverflow.com/questions/1007082/tell-applescript-to-build-xcode-project

    shazron

    March 19, 2011 at 12:10 am

  6. Hi, the link to the script doesn’t work, please could you fix as it looks exactly what I need.

    Many thanks

    MandyW

    October 25, 2011 at 8:13 pm

  7. @MandyW I’ve updated the script link.

    shazron

    October 25, 2011 at 9:58 pm

  8. The link to ios-sim appears to be broken, but this link works: https://github.com/phonegap/ios-sim

    tweisbach (@thweisbach)

    December 14, 2012 at 8:19 am

    • Thanks! Updated. The post was written before we took over maintenance of that repo.

      shazron

      December 14, 2012 at 8:21 am


Leave a comment