简体   繁体   English

armv6和armv7的条件编译

[英]Conditional compiling for armv6 and armv7

I have a published application which supports both amrv6 and armv7. 我有一个已发布的应用程序,它同时支持amrv6和armv7。 Now I have an upgrade which is only compliant with armv7 (I added an external library which depends on armv7). 现在我有一个仅与armv7兼容的升级(我添加了一个依赖于armv7的外部库)。 When I try to submit the app to the store it I get the error detailed in 当我尝试将应用程序提交到商店时,我会收到详细信息

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. 我的问题是我的代码依赖于一个只与armv7兼容的库。 If I change the properties of my project to support both armv6 and armv7 I get a compilation error (details below). 如果我更改项目的属性以支持armv6和armv7,我会收到编译错误(详情如下)。 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. 我需要能够编译支持这两种体系结构的代码:使用我依赖于armv6的库的armv7编译有一个不依赖于库的不同代码。

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

Thanks in advance 提前致谢

Well i realized my last answer in not the correct one... Apple said that is impossible but this is not really true... thanks to Jim , i search little more and i found one way to do it.. 好吧,我意识到我的最后一个答案不是正确的... Apple说这是不可能的,但这不是真的...感谢Jim ,我搜索了一点,我找到了一种方法来做到这一点..

  1. Remove lib from "Build Phases" “构建阶段”中删除lib
  2. Add both architectures in "Other Linker Flags" (Build Settings) , for that you need click in + and add armv6 and armv7 “其他链接器标志”(Build Settings)中添加两种体系结构,为此需要单击+并添加armv6和armv7
  3. Add the lib in armv7.. with -l 使用-l在armv7 ..中添加lib
  4. Don't forget #if defined _ARM_ARCH_7 in your code 不要忘记代码中#if defined _ARM_ARCH_7

This is like Jim answered but more detailed. 这就像吉姆回答但更详细。

I received this answer from Apple: 我收到Apple的回答:

You cannot conditionally build your app for either armv6 or armv7. 您无法有条件地为armv6或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构建,因为您的应用程序支持这两种体系结构......您可以通过将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

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. 您必须从正常的库列表中删除库,并通过仅为armv7手动传递-L参数来添加它。 You'll probably also have to add in a preprocessor definition so you can put #ifdef s around the code that calls the library. 您可能还需要添加预处理器定义,以便将#ifdef放在调用库的代码周围。

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. 编辑:考虑一下,您可以通过在构建阶段部分将库标记为可选,以更简单的方式执行此操作。

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中删除不良架构,你就可以了:)

I had the same problema so I switched: "Build Activate Architecture Only" to yes (in the Target -> Build Settings" 我有同样的问题所以我切换:“Build Activate Architecture Only”为yes(在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构建它

I had this problem for the Google Analytics iOS SDK. 我在Google Analytics iOS SDK上遇到了这个问题。 Merely replacing the library with the latest version is what resolved this problem for me. 仅仅用最新版本替换库就解决了这个问题。

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

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