Xcode:基于架构的条件构建设置(设备(ARM)与模拟器(i386))

Xcode: Conditional Build Settings based on architecture (Device (ARM) vs Simulator (i386))(Xcode:基于架构的条件构建设置(设备(ARM)与模拟器(i386)))

本文介绍了Xcode:基于架构的条件构建设置(设备(ARM)与模拟器(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:基于架构的条件构建设置(设备(ARM)与模拟器(i386))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Xcode:基于架构的条件构建设置(设备(ARM)与模拟器(i386))

基础教程推荐