2012-10-01 58 views
2

我想從命令行運行模擬器。有什麼方法可以找到模擬器路徑命令行。蘋果經常改變模擬器的位置,如查找iOS模擬器應用程序的路徑

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

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

有沒有什麼辦法從終端找到模擬器路徑。 ?

+0

使用「NSTemporaryDirectory()」。看這個 - http://stackoverflow.com/questions/1108076/where-does-the-iphone-simulator-store-its-data/32087374#32087374 – Shubhendu

+0

@Shubhendu OP的問題是「從終端」,而不是「從代碼「;-) – AliSoftware

回答

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一個xcodebuild聯編工具的路徑SDK,然後從這裏扣除路徑:

    # 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 
    
+0

使用」NSTemporaryDirectory()「。看這個 - http://stackoverflow.com/questions/1108076/where-does-the-iphone-simulator-store-its-data/32087374#32087374 – Shubhendu

相關問題