Finding the path of the iOS Simulator app

ios, ios-simulator, xcode, xcode4.2

Solution

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

Problem

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

Original source

Related problems