Wednesday 28 January 2015

How to create build for simulator and also run that build in simulator?

Generate a Simulator Build

In order to generate a simulator build you will:
i)Find the folder containing your xcode project.
ii)Open a terminal and run a couple of commands to generate the build.
1)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:
2)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}
If you are using workspace instead of xcodeproj then don't use above command instead use:
xcodebuild -arch i386 -sdk iphonesimulator{version} -workspace[projectName].xcworkspace - scheme [projectName]
Or you can use:
xcodebuild -workspace {project name}.xcworkspace -scheme {project name} -arch i386 -sdk iphonesimulator8.1

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.

Your build path is
{base directory}/build/Release-iphonesimulator/{projectname}.app

If you build the workspace.
{Derive data directory}/build/Release-iphonesimulator/{projectname}.app
Yes, it is your final Simulator Build.

How to run it on Simulator?

your simulator build by running command:
ios-sim launch
Also verify that the app opens in the simulator.

How to install ios-sim?

If you get error with error message:
-bash: ios-sim: command not found.

Follow the step to install the ios-sim
Download node.js from http://nodejs.org/download/ for your system.
Open node package file.
Install it on your system.
Open the terminal and run the command: $ sudo npm install ios-sim -g
Now ios-sim is install on your system.

0 comments:

Post a Comment