如何从命令行构建 Xcode 项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45681264/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to build Xcode project from the command line?
提问by 14wml
I've tried reading the Xcode Tools documentationApple provides, so that I can use the Terminal to build a .app
file and run the resulting app on the Simulator. Essentially what I want to do is do the same thing as Cmd
+ R
does on Xcode.
我尝试阅读Apple 提供的Xcode 工具文档,以便我可以使用终端构建.app
文件并在模拟器上运行生成的应用程序。基本上我想做的就是做和Cmd
+R
在 Xcode 上做的一样的事情。
So far I've attempted to build my .xcodeproj
like this:
到目前为止,我已经尝试.xcodeproj
像这样构建我的:
xcodebuild -configuration Debug build
However, when I install & run it on the Simulator I get an app w/ a black screen:
但是,当我在模拟器上安装并运行它时,我得到了一个带黑屏的应用程序:
// Boot device
xcrun simctl boot "iPhone 7"
// Install app
xcrun simctl install "iPhone 7" "/Users/.../MyApp/build/Debug-iphoneos/MyApp.app"
// Open simulator
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
// Launch app using its bundle id
xcrun simctl launch booted "com.example.apps.MyApp"
Not to mention the xcrun simctl launch booted "com.example.apps.MyApp"
line never terminates and on the Simulator it keeps trying to open and reopen the app, but the app only ever shows a black screen.
更不用说该xcrun simctl launch booted "com.example.apps.MyApp"
线路永远不会终止,并且在模拟器上它不断尝试打开和重新打开应用程序,但该应用程序只显示黑屏。
If anyone could tell me what I'm doing wrong with the building of the.xcodeproj
that would be great!
如果有人能告诉我我在建造这座建筑时做错了什么.xcodeproj
,那就太好了!
回答by Tsunamis
After having a working configuration in Xcode, open a shell and navigate to the directory, where your <NAME>.xcodeproj
resides.
在 Xcode 中完成工作配置后,打开一个 shell 并导航到您<NAME>.xcodeproj
所在的目录。
After running:
运行后:
xcodebuild -list -project <NAME>.xcodeproj/
you see a list of Schemes.
你会看到一个Schemes列表。
Copy the desired scheme name and run:
复制所需的方案名称并运行:
xcodebuild -scheme <SCHEME NAME> build
You can install ios-deployi.e. via:
您可以通过以下方式安装ios-deployie:
npm install -g ios-deploy
Copy the app path from the end of the xcodebuildoutput and run:
从xcodebuild输出的末尾复制应用程序路径并运行:
ios-deploy --debug --bundle <APP PATH>
Now the app should be launched on i.e. a connected device.
现在应用程序应该在 ie 连接的设备上启动。