我想要通过命令行来运行模拟器。是否有办法通过命令行找到模拟器路径?苹果经常更改模拟器的位置,例如:
/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator
/Applications ........ / IOS simulato....
有没有办法从终端找到模拟器路径呢?
我想要通过命令行来运行模拟器。是否有办法通过命令行找到模拟器路径?苹果经常更改模拟器的位置,例如:
/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator
/Applications ........ / IOS simulato....
以下是两个建议:
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