本文轉自同事zz的博客http://archerzz.cn/ios/xcode-install-app.html
原由
很多時候,為了學習了解別人的app,很多時候我們是直接拿別人的app安裝在自己的模擬器上面。在xcode7之前,模擬器上app的安裝步驟都比較簡單,直接將對應[NSBundle mainBundle]路徑下的app拷貝,再放到對應的模擬器路徑下即可。在xcode7之后,這個方法變得不可用。在這里就告訴大家怎么在xcode7的模擬器中安裝app。
步驟
1.首先拿到別人的app包文件
2.打開模擬器,選擇要安裝模擬器的版本(如:iphone6或iphone6s)
3.打開終端,在終端中輸入 xcrun simctl install booted /path/to/your.app ("/path/to/your.app"為你將要安裝的.app文件的路徑)
一般來講,此時app便會在你的模擬器安裝成功了。若沒能安裝成功的話需要配置一些其他文件。
安裝失敗時配置方法
如果沒有安裝Command Line Tool,系統會自動提示安裝,點擊install即可
如果出現以下問題:
xcrun simctl install booted /path/xxx.app
xcrun: error: unable to find utility "simctl", not a developer tool or in PATH`
xcrun simctl install booted /path/xxx.app
xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use `xcode-select –switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools (or see `man xcode-select`)
`No devices are booted`
解決:在終端中繼續輸入`sudo xcode-select -switch xcode路徑/Contents/Developer`即可,比如我的Xcode路徑為`/Applications/Xcode.app/Contents/Developer`
那么我在終端中則會輸入為sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
至此在xcode7中安裝app的問題基本就解決了