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

3

我想要通过命令行来运行模拟器。是否有办法通过命令行找到模拟器路径?苹果经常更改模拟器的位置,例如:

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

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

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

使用 "NSTemporaryDirectory()"。查看此链接 - https://dev59.com/JnNA5IYBdhLWcg3wC5bh#32087374 - Shubhendu
@Shubhendu,原帖问题是“从终端执行”,而不是“从代码中执行”;-) - AliSoftware
1个回答

5

以下是两个建议:

  • 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
    

使用“NSTemporaryDirectory()”。查看此链接- https://dev59.com/JnNA5IYBdhLWcg3wC5bh#32087374 - Shubhendu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接