Tuesday 19 August 2014

build the iphone simulator build to check on some else simulator

Generate a Simulator Build

In order to generate a simulator build you will:
  • Find the folder containing your xcode project.
  • Open a terminal and run a couple of commands to generate the build.
  • Compress the simulator build into a zip file.

Find your Xcode project directory

The easiest way to find your Xcode project is to use Xcode itself. Control-click on your project and select Show in Finder:

Open a Terminal and Find Your Simulator SDK Version

Click on the tasks menu in finder, Open With and Terminal. This will open the finder and automatically select the .xcodeproj directory.
This will open a terminal with the right directory already opened:
Change the working directory for the shell inside of the terminal so that it's set to the parent directory:
Figure out which SDKs versions are available by running the following command in the terminal:
xcodebuild -showsdks
What you want from this output is the string for the iOS Simulator SDK. Choose the most recent version if you have more than one installed:

Build the Simulator Package

In your terminal you will want to run this command with the proper simulator SDK string replaced with the string you found in the previous step:
xcodebuild -arch i386 -sdk iphonesimulator{version}
For example:
This should generate a build. If the build was successful you should see a lot of output from the build tools followed by the string ** BUILD SUCCEEDED ** in your terminal.

Compress the Simulator Build Into a .zip File

You now need to compress the simulator build into a zip file. The build that was generated was placed into:
{base directory}/build/Release-iphonesimulator/{projectname}.app
You need to compress the .app directory. Open the finder window you used to find your build directory and find the file. Select Compress by control-clicking on the .app directory. (It may be missing the .app name depending on your Finder settings. Note that in the image below the type is Application.)
That will generate a .zip file in that directory. This is the file you need to upload to Facebook:

test your simulator build by running ios-sim launch <path to .app> and verify that the app opens in the simulator.

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication ~/Desktop/MyApp.app/MyApp


I have just found that you don't need to copy the mobile application bundle to the iPhone Simulator's folder to start it on the simulator, as described in the forum. That way you need to click on the app to get it started, not confortable when you want to do testing and start the app numerous times.

There are undocumented command line parameters for the iOS Simulator, which can be used for such purposes. The one you are looking for is: -SimulateApplication

An example command line starting up YourFavouriteApp:

    /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication path_to_your_app/YourFavouriteApp.app/YourFavouriteApp

This will start up your application without any installation and works with iOS Simulator 4.2 at least. You cannot reach the home menu, though.

There are other unpublished command line parameters, like switching the SDK. Happy hunting for those...

No comments:

Post a Comment