查找iOS模拟器应用程序的路径

时间:2012-10-01 15:08:54

标签: ios xcode xcode4.2 ios-simulator

我想从命令行运行模拟器。有没有办法通过命令行找到模拟器路径。 Apple经常更改模拟器位置,如

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

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

有没有办法从终端找到模拟器路径。 ?

1 个答案:

答案 0 :(得分:4)

以下是两条建议:

  • 您可以使用xcode-select打印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
    
  • 您可以使用xcrun在iphonesimulator SDK中查找xcodebuild工具的路径,然后从此处扣除路径:

    # 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