使用xcodebuild在模拟器上构建和运行应用 [英] Build and run an app on simulator using xcodebuild

查看:397
本文介绍了使用xcodebuild在模拟器上构建和运行应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现以下目标:使用xcodebuildios-sim生成并运行.app应用程序.

I have the following goal to achieve: build and run an .app application using 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"

每次我收到以下消息:

服务指定的程序不包含所请求的内容之一 体系结构:?

Program specified by service does not contain one of the requested architectures: ?

发生了什么事,该应用程序无法运行?

What is happening, that the app doesn't run?

注意:如果我针对从Xcode构建的.app(派生数据中包含的那个)运行第二个命令(ios-sim...),则该程序运行正常.

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.

推荐答案

好.找出问题所在.

您需要指定正确的destination.例如.

You need to specify the correct destination. For example.

xcrun xcodebuild \
  -scheme $XCODE_SCHEME \
  -project $XCODE_PROJECT \
  -configuration Debug \
  -destination 'platform=iOS Simulator,name=iPhone 6 Plus,OS=9.1' \
  -derivedDataPath \
  build

通过这种方式,Xcode将创建包含您的产品的文件夹(称为build)(特别是Debug-iphonesimulator). build目录是在您运行xcodebuild命令的目录中创建的.

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.

现在,您可以指向该文件夹以运行ios-sim命令(请参见 ios-sim 以获取更多参考)或simctl(请参见 iOS 8 :构建自定义模拟器在Commmand Line中构建并运行iOS应用以获取更多信息).

Now you can point that folder in order to run the ios-sim command (see ios-sim for more references) or simctl (see iOS 8: Building custom simulators and Build And Run iOS Apps In Commmand Line for more info).

这篇关于使用xcodebuild在模拟器上构建和运行应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆