xcode 是否有编译器标志来指示缺少 armv7s 架构

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12405378/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:28:57  来源:igfitidea点击:

Is there a compiler flag to indicate lack of armv7s architecture

iosxcodecompiler-constructionlinkercpu-architecture

提问by coneybeare

With the iPhone 5 and other armv7s devices now appearing, there are compatibility problems with existing (closed-source) 3rd-party frameworks such as Flurry which are built without this newer architecture.

随着 iPhone 5 和其他 armv7s 设备的出现,现有(封闭源代码)第 3 方框架(如 Flurry 没有这种较新的架构而构建)存在兼容性问题。

One option is to wait until they release a new build, but I was hoping there might be a compiler flag or something I can use in my Xcode project that would let the linker know not to expect armv7s architecture from this framework, and use the armv7 instead. Does anything like this exist?

一种选择是等到他们发布新版本,但我希望可能有一个编译器标志或我可以在我的 Xcode 项目中使用的东西,让链接器知道不要期望来自这个框架的 armv7s 架构,并使用 armv7反而。这样的东西存在吗?

回答by catlan

It's not possible to load a framework which doesn't include the targeted architecture.

无法加载不包含目标架构的框架。

What you could do is only ship a armv7 app until the frameworks are updated. The app will still work on the iPhone 5, just don't use the latest performance optimizations it offers.

您可以做的只是在框架更新之前发布 armv7 应用程序。该应用程序仍可在 iPhone 5 上运行,只是不要使用它提供的最新性能优化。

Or if you could live without the framework on the new architecture you could weak link it. But then you need to check in your code if it is loaded everywhere you use stuff from the framework.

或者,如果您可以在没有新架构上的框架的情况下生活,您可以将其弱链接。但是你需要检查你的代码是否在你使用框架中的东西的任何地方加载。

回答by Ertebolle

There used to be a linker flag in GCC, allow_sub_type_mismatches, which would let you mix and match ARM architecture versions in linked libraries, but they seem to have taken that away in recent versions of Xcode.

GCC 中曾经有一个链接器标志allow_sub_type_mismatches,它可以让您在链接库中混合和匹配 ARM 体系结构版本,但它们似乎在最近版本的 Xcode 中已经取消了。

However, this can actually be hacked around in a different way; make a copy of the framework, view its contents, open up the actual code library file inside of it in a hex editor, and do the following replace all:

然而,这实际上可以以不同的方式被破解;制作框架的副本,查看其内容,在十六进制编辑器中打开其中的实际代码库文件,然后执行以下操作替换所有内容:

CEFAEDFE 0C000000 09000000

to

CEFAEDFE 0C000000 0B000000

What you're basically doing is changing the header inside of each code object to identify it as ARMv7s rather than an ARMv7 code - the instruction sets are backwards compatible (or seem to be, anyway), so it should run fine even with this hack, though I have to admit that we won't know that for certain until we actually get a chance to test it on an iPhone 5.

您基本上要做的是更改每个代码对象内部的标头以将其标识为 ARMv7s 而不是 ARMv7 代码 - 指令集是向后兼容的(或者似乎是,无论如何),因此即使使用此 hack 也应该可以正常运行,但我不得不承认,在我们真正有机会在 iPhone 5 上测试它之前,我们不会确切地知道这一点。

Anyway, once you've modified the framework, simply add both versions to your project and link to the appropriate one from each architecture. You might also be able to create a new single framework by using lipoto merge the modified and original libraries.

无论如何,一旦您修改了框架,只需将两个版本都添加到您的项目中,并链接到每个架构中的相应版本。您还可以通过使用lipo合并修改后的库和原始库来创建新的单一框架。