3

I want to run the simulator from the command line. Is there any way to find the simulator path through command line. Apple frequently changes the simulator location like

/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator

/Applications ........ / IOS simulato....

Is there any way to find the simulator path from terminal. ?

Flexo
  • 87,323
  • 22
  • 191
  • 272
Muthu
  • 1,550
  • 10
  • 36
  • 62
  • Use "NSTemporaryDirectory ()". Look this- http://stackoverflow.com/questions/1108076/where-does-the-iphone-simulator-store-its-data/32087374#32087374 – Shubhendu Aug 19 '15 at 05:46
  • @Shubhendu the OP question was "from the terminal", not "from code" ;-) – AliSoftware Aug 19 '15 at 09:54

1 Answers1

5

Here are two suggestions:

  • You can use xcode-select to print the path to Xcode:

    # This returns sthg like "/Applications/Xcode.app/Contents/Developer"
    XCODEPATH=$(xcode-select --print-path)
    # Then build the rest of the path to the simulator SDK
    SIMSDKPATH=${XCODEPATH}/Platforms/iPhoneSimulator.platform/Developer
    # And add the rest of the path to the Simulator app
    SIMULATORPATH=$(SIMSDK}/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator
    
  • You can use xcrun to find the path of a xcodebuild tool in the iphonesimulator SDK, then deducting the path from here:

    # This returns sthg like "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc"
    GCCPATH=$(xcrun -sdk iphonesimulator -find gcc)
    # Then go up 3 directories
    SIMSDKPATH=$(dirname $(dirname $(dirname ${GCCPATH})))
    # And down to the Simulator app
    SIMULATORPATH=${SIMSDKPATH}/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator
    
AliSoftware
  • 32,623
  • 6
  • 82
  • 77
  • Use "NSTemporaryDirectory ()". Look this- http://stackoverflow.com/questions/1108076/where-does-the-iphone-simulator-store-its-data/32087374#32087374 – Shubhendu Aug 19 '15 at 05:46