xcode 在 iOS 项目和 iOS 模拟器中使用 xcodebuild

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20504851/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:25:07  来源:igfitidea点击:

Using xcodebuild with an iOS Project and the iOS Simulator

iosxcodeios-simulatorxcodebuild

提问by ericg

This questionis related, but does not resolve the specific issue I am having.

这个问题是相关的,但不能解决我遇到的具体问题。

I am using Xcode 4.6.3 under OS X 10.7.5.

我在 OS X 10.7.5 下使用 Xcode 4.6.3。

I simply created the default project for a single view iOS app and made no changes to the project settings. The project, of course, builds in Xcode for the iOS Simulator. However, when I try to use xcodebuild from the command line, xcodebuild fails.

我只是为单视图 iOS 应用程序创建了默认项目,并且没有对项目设置进行任何更改。当然,该项目是在 Xcode 中为 iOS 模拟器构建的。但是,当我尝试从命令行使用 xcodebuild 时,xcodebuild 失败。

The project name is just: temp

项目名称只是:temp

I tried:

我试过:

xcodebuild -scheme temp -sdk iphonesimulator6.1

and that produced the results:

结果如下:

Build settings from command line:
    SDKROOT = iphonesimulator6.1

=== BUILD NATIVE TARGET temp OF PROJECT temp WITH CONFIGURATION Debug ===
Check dependencies
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).


** BUILD FAILED **


The following build commands failed:
    Check dependencies
(1 failure)

Based on the other SO question, I tried:

基于另一个 SO 问题,我尝试过:

xcodebuild ARCHS="armv7 armv7s" ONLY_ACTIVE_ARCH=NO -scheme temp -sdk iphonesimulator6.1

and got similar results:

并得到了类似的结果:

Build settings from command line:
    ARCHS = armv7 armv7s
    ONLY_ACTIVE_ARCH = NO
    SDKROOT = iphonesimulator6.1

=== BUILD NATIVE TARGET temp OF PROJECT temp WITH CONFIGURATION Debug ===
Check dependencies
No architectures to compile for (ARCHS=armv7 armv7s, VALID_ARCHS=i386).


** BUILD FAILED **


The following build commands failed:
    Check dependencies
(1 failure)

What xcodebuild command do I need to execute to be able to build with xcodebuild?

我需要执行什么 xcodebuild 命令才能使用 xcodebuild 进行构建?

Thank you.

谢谢你。

采纳答案by J. Paulding

UPDATED: Seems like many folks have trouble of this sort in xcode 4, and the general solution seems to be to force the architecture you need and disable 'active only', which is what you had tried to do... but for the simulator, you need to specify i386 instead of arm*, like this:

更新:似乎很多人在 xcode 4 中都有这种问题,一般的解决方案似乎是强制你需要的架构并禁用“仅活动”,这就是你试图做的......但对于模拟器,您需要指定 i386 而不是 arm*,如下所示:

xcodebuild ARCHS="i386" ONLY_ACTIVE_ARCH=NO -scheme temp -sdk iphonesimulator6.1

*ORIGINAL response which spawned comment thread below and still has some valuable reference: It sounds like your project my not be set up for 64-bit. You should be able to add arm64 to your valid architectures in your build settings and I believe xcode will automatically treat it as x86_64 for simulator builds.

*原始回复产生了下面的评论线程,但仍有一些有价值的参考:听起来您的项目没有针对 64 位进行设置。您应该能够在构建设置中将 arm64 添加到有效架构中,我相信 xcode 会自动将其视为 x86_64 用于模拟器构建。

For the second thing you attempted, you are hard-coding your architectures to IPhone architectures while targeting a simulator, which I believe is why the architectures are not available there.

对于您尝试的第二件事,您正在将架构硬编码为 iPhone 架构,同时针对模拟器,我相信这就是架构在那里不可用的原因。