查找iOS Simulator应用程序的路径

Mut*_*thu 3 xcode ios ios-simulator xcode4.2

我想从命令行运行模拟器。有什么方法可以通过命令行找到模拟器路径。苹果经常更改模拟器的位置,例如

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

/Applications ........ / IOS simulato....
Run Code Online (Sandbox Code Playgroud)

有什么办法可以从终端找到模拟器路径。?

Ali*_*are 5

这里有两个建议:

  • 您可以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
    
    Run Code Online (Sandbox Code Playgroud)
  • 您可以用来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
    
    Run Code Online (Sandbox Code Playgroud)