xcode armv6 和 armv7 的条件编译
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9601142/
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
Conditional compiling for armv6 and armv7
提问by silvaric
I have a published application which supports both amrv6 and armv7. Now I have an upgrade which is only compliant with armv7 (I added an external library which depends on armv7). When I try to submit the app to the store it I get the error detailed in
我有一个支持 amrv6 和 armv7 的已发布应用程序。现在我有一个仅与 armv7 兼容的升级(我添加了一个依赖于 armv7 的外部库)。当我尝试将应用程序提交到商店时,我收到了详细说明的错误
I understand the previous error and I need to change my app so it supports both architectures. My problem is that my code depends on a library which is only compliant with armv7. If I change the properties of my project to support both armv6 and armv7 I get a compilation error (details below). I need to be able to compile the code with support for both architectures: armv7 compiles using the library I depend on armv6 has a different code which does not depend on the library.
我了解之前的错误,我需要更改我的应用程序,以便它支持两种架构。我的问题是我的代码依赖于仅符合 armv7 的库。如果我更改项目的属性以同时支持 armv6 和 armv7,则会出现编译错误(详情如下)。我需要能够编译支持这两种架构的代码:armv7 使用我依赖的库进行编译 armv6 有一个不依赖于库的不同代码。
How can I achieve this?
我怎样才能做到这一点?
Error details:
错误详情:
? the compile crash is in one Lib file (.a) and the error says :
ld: warning: directory not found for option '-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc/arm-apple-darwin10/4.0.1' ld: in /Users/.../(lib file).a, file is universal but does not contain a(n) armv6 slice for architecture armv6 Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
? the compile crash is in one Lib file (.a) and the error says :
ld: warning: directory not found for option '-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc/arm-apple-darwin10/4.0.1' ld: in /Users/.../(lib file).a, file is universal but does not contain a(n) armv6 slice for architecture armv6 Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
Thanks in advance
提前致谢
采纳答案by silvaric
Well i realized my last answer in not the correct one... Apple said that is impossiblebut this is not really true... thanks to Jim, i search little more and i found one way to do it..
好吧,我意识到我的最后一个答案不正确......苹果说这是不可能的,但这不是真的......感谢吉姆,我搜索了更多,我找到了一种方法来做到这一点......
- Remove lib from "Build Phases"
- Add both architectures in "Other Linker Flags" (Build Settings), for that you need click in
+
and add armv6 and armv7 - Add the lib in armv7.. with
-l
- Don't forget
#if defined _ARM_ARCH_7
in your code
- 从“构建阶段”中删除 lib
- 在“Other Linker Flags”(构建设置)中添加两种架构,为此您需要单击
+
并添加 armv6 和 armv7 - 在 armv7.. 中添加 lib
-l
- 不要忘记
#if defined _ARM_ARCH_7
在你的代码中
This is like Jim answered but more detailed.
这就像吉姆回答的一样,但更详细。
回答by silvaric
I received this answer from Apple:
我从苹果那里收到了这个答案:
You cannot conditionally build your app for either armv6 or armv7. Your static library must be built for both armv6 and armv7 since your application supports both of these architectures...You can drop support for armv6 by setting your iOS deployment target to 4.3 or higher.
您不能有条件地为 armv6 或 armv7 构建您的应用程序。您的静态库必须同时为 armv6 和 armv7 构建,因为您的应用程序支持这两种架构……您可以通过将 iOS 部署目标设置为 4.3 或更高版本来放弃对 armv6 的支持。
Basically i need to ask the developer of the library to build for both of there architectures ( =/ ) or i set my minimum target to 4.3 and only armv7
基本上,我需要要求库的开发人员为这两种架构(=/)构建,或者我将我的最低目标设置为 4.3 并且只设置 armv7
回答by Jim
In your build settings, if you hover over a setting, a +
appears that you can click on to scope a setting to a particular architecture. You'll have to remove the library from the normal list of libraries and add it in by passing the -L
argument manually only for armv7. You'll probably also have to add in a preprocessor definition so you can put #ifdef
s around the code that calls the library.
在您的构建设置中,如果您将鼠标悬停在某个设置上,+
则会出现一个,您可以单击它以将设置范围限定为特定架构。您必须从正常的库列表中删除该库,然后通过-L
仅为 armv7 手动传递参数来添加它。您可能还必须添加预处理器定义,以便您可以将#ifdef
s放在调用库的代码周围。
Edit:Thinking about it, you might be able to do it in a simpler way by marking the library as optional in the build phases section.
编辑:考虑一下,您可以通过在构建阶段部分将库标记为可选来以更简单的方式来完成。
回答by marciokoko
I'm sorry, I pasted the wrong thing from clipboard.
对不起,我从剪贴板粘贴了错误的东西。
I meant to say:
我的意思是:
Simply remove the bad architecture from Valid Architectures in Target Aguilar Settings and you're good to go :)
只需从 Target Aguilar Settings 中的 Valid Architectures 中删除不良架构即可:)
回答by vedran
I had the same problema so I switched: "Build Activate Architecture Only" to yes (in the Target -> Build Settings"
我遇到了同样的问题,所以我切换了:“仅构建激活架构”为是(在目标 -> 构建设置中)
This works...for now.
这工作......现在。
I imagine my app will not work on an iPhone 5, but I will have to wait till the supplier of the static library I am using builds it for armv7/armv7s
我想我的应用程序不能在 iPhone 5 上运行,但我必须等到我使用的静态库的供应商为 armv7/armv7s 构建它
回答by Stunner
I had this problem for the Google Analytics iOS SDK. Merely replacing the library with the latest version is what resolved this problem for me.
我在 Google Analytics iOS SDK 上遇到了这个问题。仅仅用最新版本替换库就为我解决了这个问题。