How to install iPhone application in iPhone Simulator

181,420

Solution 1

Please note: this answer is obsolete, the functionality was removed from iOS simulator.

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...

Solution 2

You can install apps in simulator from Xcode 8.2

From Xcode 8.2,You can install an app (*.app) by dragging any previously built app bundle into the simulator window.

Note: You cannot install apps from the App Store in simulation environments.

Solution 3

This thread discusses how to install the binary on the simulator. I've done it and it works: http://forums.macrumors.com/showthread.php?t=547557

From the thread:

Look inside your ~/Library/Application Support/iPhone Simulator/User/Applications/ directory and see what happens inside this directory when you install and run apps using XCode, and also when you delete apps using the Simulator.

You can run the Simulator by itself (without starting XCode).

If you start the Simulator, delete an app, quit the Simulator, put back copies of the files that were deleted from the support directory, and restart the Simulator, the app will reappear in the Simulator. Email those files with instructions about how to copy them into the appropriate support directory.

Solution 4

If you're looking to do this XCode 5+, I found this is the easiest method:

Install ios-sim:

npm install -g ios-sim

Then simply execute:

ios-sim launch ./mySample.app --devicetypeid com.apple.CoreSimulator.SimDeviceType.iPhone-6

In which you can switch up your device type. Simple, fast, and it actually works.

Solution 5

From Xcode v4.3, it is being installed as application. The simulator is available at

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iOS\ Simulator.app/

Share:
181,420
Admin
Author by

Admin

Updated on November 14, 2020

Comments

  • Admin
    Admin over 3 years

    I have a mySample.app file - an iPhone application developed by xcode.

    How do I run this (only mySample.app file) application using my xcode?

  • Albert
    Albert almost 14 years
    It builds fine for me and gives me the error "Failed to launch simulated application: Unknown error.". It starts the simulator in iPad mode with a blank screen. When I switch to home screen, it doesn't show my app.
  • racs
    racs over 13 years
    Unfortunately, this solution has its limitations: you cannot configure the application, and the preadjusted settings won't affect the run, doesn't matter whether you specified the exact preinstalled application for the simulation or not. The possible command line arguments, what I have found so far: SimulateDevice, SimulateRestart, SessionOnLaunch, currentSDKRoot - there might be others, though.
  • sj26
    sj26 over 12 years
    strings /Developer/Platforms/iPhoneSimulator.platform/Developer/Appl‌​ications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator gives the follow nearby SimulateApplication: * LocationLongitude * LocationLatitude * LocationMode * StayInFront * windowOrientation * SessionOnLaunch * SimulateRestart * MobileSafari * Safari * SimulateDevice * SimulateApplication * LocationScenario
  • an0
    an0 about 12 years
    It this method still working for Xcode 4.3 and iOS 5? I encountered this problem using it: skitch.com/an00na/8dj8r/simulator.
  • gaige
    gaige about 12 years
    I still get it to work with 4.3.1. Although I did get this error when I used the path to the .app bundle instead of the executable within the bundle (i.e. foo.app/foo ).
  • Paolo Stefan
    Paolo Stefan almost 12 years
    This doesn't work on my MacOS 10.6.8. The myFavoriteApp.app/myFavoriteApp (Flash compiled) just crashes at launch.
  • cheshirekow
    cheshirekow almost 12 years
    Very nice @sj26. By trial and error I've determined that (for the 5.1 simulator) "SimulateDevice" takes the following parameters: "iPhone" "iPhone (Retina)" "iPad" "iPad (Retina)"
  • cheshirekow
    cheshirekow almost 12 years
    On my system, with Xcode 4.3, it's in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneS‌​imulator.platform/De‌​veloper/Applications‌​/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator
  • rooftop
    rooftop almost 12 years
    @cheshirekow This is a really helpful piece of info, I hope it finds it's way out of being buried in a comment.
  • sites
    sites about 11 years
    how to find that path as versions pass?
  • Dale Emery
    Dale Emery over 10 years
    The iOS 7 SDK no longer seems to take the -SimulateApplication parameter. Any ideas how to do this in iOS 7?
  • racs
    racs over 10 years
    I am afraid this function was removed from the simulator. Some other parameters are still available, like the SimulateDevice and SimulatorWindowCenterX - SimulatorWindowCenterY, but I couldn't find any sign of a string that refers to launching an application in any direct or indirect way. However, I discovered that any string specified as parameter in the command line will be opened in Safari on a path relative to the simulator's Applications folder. I am not sure how useful is that (maybe it is a documented feature).
  • Perry
    Perry about 10 years
    Sadly this no longer works (at least as of Xcode 5.0, possibly earlier)
  • RameshVel
    RameshVel about 10 years
    @Perry, is there any alternatives?
  • Perry
    Perry about 10 years
    @RameshVel I recently discovered that the old iphonesim project which provided a command line interface to the XCode Simulator has an active fork at github.com/phonegap/ios-sim It works well within the limitations imposed by Apple.
  • RameshVel
    RameshVel about 10 years
    @Perry, yep i am using ios-sim now. it works fine now. thanks
  • Rahul Mathur
    Rahul Mathur almost 10 years
    When i try to run my app it gives following error -bash: /Developer/Platforms/iPhoneSimulator.platform/Developer/Appl‌​ications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator: No such file or directory Can you please tell what wrong is happening?
  • racs
    racs almost 10 years
    Maybe you need to wrap the arguments into quoting marks because of the spaces.
  • ptim
    ptim over 9 years
    @RahulMathur works for me: /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app/Contents/MacOS/iOS\ Simulator
  • user1568901
    user1568901 almost 8 years
    Appears this function was removed from the simulator. Does not work on current version.
  • Jeff Huijsmans
    Jeff Huijsmans over 7 years
    According to this comment, brew isn't supported anymore. Recommended way is now npm install -g ios-sim.
  • Abhijith
    Abhijith over 7 years
    Its possible from Xcode 8.2. stackoverflow.com/a/41671233/1522584
  • Abhijith
    Abhijith over 7 years
    Its possible from Xcode 8.2. stackoverflow.com/a/41671233/1522584