Xcode:基于架构的条件构建设置(Device (ARM) vs Simulator (i386)) [英] Xcode: Conditional Build Settings based on architecture (Device (ARM) vs Simulator (i386))

查看:19
本文介绍了Xcode:基于架构的条件构建设置(Device (ARM) vs Simulator (i386))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 iPhone 应用程序,它必须在模拟器和设备上运行.但是,我使用的是外部编译的库,其中一个版本用于模拟器,另一个用于设备(​​不同的 CPU).

I'm building an iPhone app that has to run on both the simulator and the device. However I'm using an externally compiled library that has one version for the simulator and one for the device (different CPU).

我该怎么做?我来自 Visual C++,所以我是 Xcode 的新手,我找不到方法.

How can I do it? I'm coming from Visual C++ so I'm new to Xcode, and I can't find the way to do it.

编辑,2016 年 3 月:这个问题是在大约 6 年前的 2009 年 7 月提出的.从那以后,Xcode 发生了很大变化,但我想有些东西仍然存在.例如,现在接受的答案不是 Xcode v3 中的一个选项.

EDIT, March 2016: this question was asked on July 2009, almost 6 years ago. Much has changed in Xcode since, but I guess some stuff still holds. The now-accepted answer, for example, wasn't an option in Xcode v3.

推荐答案

我在集成 Adob​​e Omniture 的AppMeasurement"库时遇到了这个问题,该库目前为 3 种架构编译:libAppMeasurement-iOSSimulator.a、libAppMeasurement-iOSDevice.a、和 libAppMeasurement-iOSDevice-armv7.a.

I had this problem when integrating Adobe Omniture's "AppMeasurement" library, which currently comes compiled for 3 architectures: libAppMeasurement-iOSSimulator.a, libAppMeasurement-iOSDevice.a, and libAppMeasurement-iOSDevice-armv7.a.

虽然这里的其他答案基本正确,但我最终不得不去其他地方真正理解并解决问题.

While the other answers here are substantially correct, I ended up having to go elsewhere to truly understand and then fix the problem.

第 1 步:了解问题

这个 博文 很好地解释了整个问题.它给出了解决在 Xcode 3 中的问题的从头到尾的说明.请参阅下面的 Xcode 4.

This blog post does a great job of explaining the overall issue. It gives start-to-finish instructions for solving the problem in Xcode 3. See below for Xcode 4.

注意:您可以尝试跳过他所说的添加静态库然后删除它们的部分.下次我这样做时,我可能只添加头文件,然后直接跳到编辑其他链接器标志.

Note: You might try skipping the bit where he says to add the static libraries and then delete them. The next time I do this, I'll probably just add the header file(s), then skip straight to editing Other Linker Flags.

步骤 2. Xcode 4 中的条件构建设置

这个StackOverflow 页面解释了设置的新方法Xcode 4 中的条件构建设置.提示:构建设置"选项卡上的文本字段已启用拖放;一旦您准备好条件构建设置以在其他链接器标志下进行编辑,您只需将静态库文件拖到文本字段上,Xcode 将自动输入(希望是相对的)路径.

This StackOverflow page explains the new way to set conditional build settings in Xcode 4. Tip: The text fields on the Build Settings tab are drag-&-drop enabled; once you have your conditional build setting ready for editing under Other Linker Flags, you can just drag the static library file right onto the text field and Xcode will automatically enter a (hopefully relative) path.

这是我收到缺少所需架构 i386"警告后我的其他链接器标志的屏幕截图,该警告消失且没有构建错误:

Here's a screenshot of my Other Linker Flags once I got the "missing required architecture i386" warning to go away with no build errors:

__

这篇关于Xcode:基于架构的条件构建设置(Device (ARM) vs Simulator (i386))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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