xcode 使用 xcodebuild 在模拟器上构建和运行应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34003723/
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
Build and run an app on simulator using xcodebuild
提问by Lorenzo B
I have the following goal to achieve: build and run an .app
application using xcodebuild
and ios-sim
.
我有以下目标要实现:.app
使用xcodebuild
and构建和运行应用程序ios-sim
。
I'm using the following script to build the application.
我正在使用以下脚本来构建应用程序。
xcrun xcodebuild \
-scheme $XCODE_SCHEME \
-project $XCODE_PROJECT \
-configuration Debug \
-destination generic/platform=iOS \
-derivedDataPath \
build
Then for running it, I'm using
然后为了运行它,我正在使用
ios-sim launch MyApp.app/ --devicetypeid "iPhone-6-Plus, 9.1"
Each time I receive the following message:
每次我收到以下消息:
Program specified by service does not contain one of the requested architectures: ?
服务指定的程序不包含所请求的体系结构之一: ?
What is happening, that the app doesn't run?
发生了什么,应用程序没有运行?
Note:if I run the second command (ios-sim...
) against the .app
built from Xcode (the one contained in derived data) the procedure works fine.
注意:如果我ios-sim...
针对.app
从 Xcode 构建的命令(包含在派生数据中的命令)运行第二个命令 ( ),则该过程运行良好。
回答by Lorenzo B
Ok. Figured out the issue.
好的。想通了这个问题。
You need to specify the correct destination
. For example.
您需要指定正确的destination
. 例如。
xcrun xcodebuild \
-scheme $XCODE_SCHEME \
-project $XCODE_PROJECT \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 6 Plus,OS=9.1' \
-derivedDataPath \
build
In this way Xcode will create the folder (called build
) containing your products (in particular look at Debug-iphonesimulator
). The build
dir is created within the dir you are running the xcodebuild
command.
通过这种方式,Xcode 将创建build
包含您的产品的文件夹(称为)(特别是查看Debug-iphonesimulator
)。该build
目录是在您运行xcodebuild
命令的目录中创建的。
Now you can point that folder in order to run the ios-sim
command (see ios-simfor more references) or simctl
(see iOS 8: Building custom simulatorsand Build And Run iOS Apps In Commmand Linefor more info).
现在您可以指向该文件夹以运行ios-sim
命令(请参阅ios-sim以获取更多参考)或simctl
(请参阅iOS 8:构建自定义模拟器和在命令行中构建并运行 iOS 应用程序以获取更多信息)。