简体   繁体   English

Xcode中的“体系结构”和“有效体系结构”选项到底是什么意思,我应该为iOS项目设置什么?

[英]What exactly do the “Architectures” & “valid architectures” options in Xcode mean, and what should I set for iOS projects?

I work with cross platform code, which means I have to build open-source C++ projects for iOS to use them in my iOS app. 我使用跨平台代码,这意味着我必须为iOS构建开源C ++项目才能在我的iOS应用中使用它们。 Sometimes I have to build my own project, sometimes I get a nice CMake setup, but no two projects seem to have exactly the same settings for these two fields. 有时我必须构建自己的项目,有时我会得到一个不错的CMake设置,但是似乎没有两个项目在这两个字段上具有完全相同的设置。

Some have "armv7", others "armv7 armv7s" and others "armv7 armv7s arm64". 一些具有“ armv7”,另一些具有“ armv7 armv7s”,另一些具有“ armv7 armv7s arm64”。 I get that "armv7" refers to a specific generation of device hardware. 我知道“ armv7”是指特定一代的设备硬件。 But does that mean if I only set "armv7" my app won't run on armv7s or the new 64bit iPad? 但这是否意味着如果我仅设置“ armv7”,我的应用程序将无法在armv7s或新的64位iPad上运行? Are these multiple architectures like having fat libraries, with separate copies for each architecture? 这些多重体系结构是否像胖库一样,每个体系结构都有单独的副本?

Then for "Architectures" there are even more options. 然后对于“建筑”,还有更多选择。 Options like "Standard Architectures(armv7, armv7s)" and others like "$(ARCHS_STANDARD_32_64_BIT)". 诸如“标准体系结构(armv7,armv7s)”之类的选项,以及诸如“ $(ARCHS_STANDARD_32_64_BIT)”之类的其他选项。 I often find these have to be changed to get things to build, without errors about i386. 我经常发现必须对这些进行更改以构建东西,而不会出现关于i386的错误。 The fact an iOS project actually gets built for Intel (simulator) as well as Arm just confuses things further for me. 一个iOS项目实际上是为Intel(模拟器)以及Arm建造的,这让我感到困惑。

I'm really after a higher level explanation how this fits together than a "use this setting" answer. 我实际上是在进行更高级别的解释之后,而不是“使用此设置”答案。 I want to be confident my app will work on the devices it is intended to, since I cannot afford all the different versions of iPad now in existence. 我想确信我的应用程序可以在预期的设备上运行,因为我无法负担目前存在的所有不同版本的iPad。 For reference, I want to support iPad 2 and up, and iOS 6/7 only. 供参考,我仅支持iPad 2和更高版本,以及iOS 6/7。

These are different instruction sets. 这些是不同的指令集。 If you're building a library, you need to build all the different instruction sets/architectures that the downstream application will require, otherwise you'll get linker errors when you try and build the app. 如果要构建库,则需要构建下游应用程序所需的所有不同指令集/体系结构,否则在尝试构建应用程序时会出现链接器错误。

This is complicated by the simulator, which needs Intel x86 or x86_64 rather than ARM. 模拟器使这变得复杂,该模拟器需要Intel x86或x86_64而不是ARM。

Based on what you select, the compiler will create fat libraries containing multiple architectures. 根据您的选择,编译器将创建包含多个架构的胖库。

There is some compatibility between the different instruction sets at runtime (for instance, 32bit will run on 64bit ) but that won't help during linking. 在运行时,不同指令集之间存在一些兼容性(例如, 32bit将在64bit上运行 ),但是在链接期间没有帮助。 If you're compiling 64bit, then the libraries you're including will need 64bit. 如果您要编译64位,则您所包含的库将需要64位。

So the short answer is set for the devices you're targeting . 因此,为您要定位设备设置了简短答案。 Eg you probably don't need armv6 any more. 例如,您可能不再需要armv6。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM