How to create Simulator Build and run on Simulator

How to generate 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.

ind 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}

If you are using workspace instead of xcodeproj
xcodebuild -arch i386 -sdk iphonesimulator{version} -workspace [projectName].xcworkspace -scheme [projectName]

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.

Your build path is
{base directory}/build/Release-iphonesimulator/{projectname}.app
If you build the workspace.
{Derive data directory}/build/Release-iphonesimulator/{projectname}.app

It is your final Simulator Build.

How to run it on Simulator?

your simulator build by running ios-sim launch <path to .app> and 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.


21 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I am using sdk 8.3 and build for x64 ! how do i build by terminal ?

    ReplyDelete
    Replies
    1. i am using iphone simulator8.3 i get a error build failed help me how to create a build

      Delete
  3. I had to add -scheme {project name} like in this SOF question
    http://stackoverflow.com/questions/23950096/generate-simulator-build

    ReplyDelete
  4. Thanks a lot its save my ton of times.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. Very informative articles :)
    Greetings from Indonesia, read GOOD ARTICLES about SEO

    ReplyDelete
  7. I thought everything was perfect until this...

    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    Showing first 200 notices only
    Showing first 200 errors only

    ** BUILD FAILED **


    The following build commands failed:
    Ld build/Release-iphonesimulator/ScribeWar.app/ScribeWar normal i386

    But I am able to build it in XCode without error...

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    iOS Training in Chennai
    Android Training in Chennai
    php Training in Chennai

    ReplyDelete
  10. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..

    Mobile App Development Company in Chennai
    Android app Development Company in Chennai
    ios app development Company in Chennai

    ReplyDelete
  11. Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...Really it was an awesome article...very interesting to read..
    please sharing like this information......
    Android training in chennai
    Ios training in chennai

    ReplyDelete
  12. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...
    Mobile App Development Company
    Mobile App Development Company
    Mobile app Development Companies

    ReplyDelete
  13. I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.
    mobile App Development Company
    Android App Development Company
    Android App Development Company

    ReplyDelete
  14. I just want to say that all the information you have given here is awesome...great and nice blog thanks sharing..Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    Web Design Development Company
    Web design Company in Chennai
    Web development Company in Chennai

    ReplyDelete
  15. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    iOS App Development Company

    ReplyDelete
  16. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Sms marketing
    Text message marketing
    Fitness SMS

    ReplyDelete
  17. To know what the best use of simulator is the first job of an Software development Company in India. Thanks for sharing this information with all of us.

    ReplyDelete