简体   繁体   English

如何制作将在iOS 5到7上运行的armv7 arm64 fat二进制文件?

[英]How do I make a armv7 arm64 fat binary that will run on iOS 5 through 7?

Apple has changed instruction sets over the years. Apple多年来改变了教学方式。 Since a single programs may need to run on more than one kind of machine, Apple uses 'fat binaries' constructed by a tool named 'lipo'. 由于单个程序可能需要在多种机器上运行,因此Apple使用由名为“lipo”的工具构建的“胖二进制文件”。 You tell Xcode to compile your program multiple times, once for each machine type, and lipo binds them together. 你告诉Xcode多次编译你的程序,每种机器类型一次,lipo将它们绑定在一起。

Apple recently came out with its fourth instruction set for iOS. Apple最近推出了针对iOS的第四个指令集。 The first phones used Armv6, from the 3GS, we had Armv7, a few new instructions were added for Armv7s, and now, the 5S adds Arm64. 第一部手机使用的是Armv6,来自3GS,我们有Armv7,为Armv7s添加了一些新指令,现在,5S增加了Arm64。

I like my programs to run under a range of operating systems, so I set my MIN_DEPLOYMENT_TARGET to 5.0, so Apple will load the program on machines from 5.0 on. 我喜欢我的程序在一系列操作系统下运行,因此我将MIN_DEPLOYMENT_TARGET设置为5.0,因此Apple将在5.0以上的机器上加载程序。 But when try that in the current version of Xcode, I get an error message saying that isn't possible in Arm64. 但是当在当前版本的Xcode中尝试时,我收到一条错误消息,说在Arm64中是不可能的。

OK, I set a conditional build settings: the MIN_DEPLOYMENT_TARGET is 5.0 for architectures other than Arm64, but it's set to 7.0 for Arm64. 好的,我设置了一个条件构建设置:对于Arm64以外的架构,MIN_DEPLOYMENT_TARGET为5.0,但Arm64的设置为7.0。 Now the program compiles, links, and lipos. 现在程序编译,链接和脂肪。 But now, since one of the compilations is iOS 7.0 only, I get a bunch of warnings that my program contains calls for older operating systems. 但是现在,由于其中一个编辑只是iOS 7.0,我得到一堆警告,我的程序包含对旧操作系统的调用。 I know that. 我知道。 It's intentional - so the program will run on those older systems. 这是故意的 - 所以程序将在那些旧系统上运行。 On an iOS 7 system, those old routines aren't called, instead, at runtime, the program calls their modern replacements. 在iOS 7系统上,不调用那些旧例程,而是在运行时,程序调用它们的现代替换。 I can get the compiler to stop complaining with: 我可以让编译器停止抱怨:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// old code here.
#pragma clang diagnostic pop

and the program works fine on iOS 7 devices, both Armv7 and Arm64. 该程序在iOS 7设备上运行良好,包括Armv7和Arm64。 A bit of diagnostic code verifies that when run on an Arm64 device, the Arm64 fork is actually being used. 一些诊断代码验证在Arm64设备上运行时,实际上正在使用Arm64分支。

Running lipo on the binary reports that it has the expected architectures in it. 在二进制文件上运行lipo报告它具有预期的体系结构。

But, and it's a big one: when I try to install the app on an iOS 5 device, Xcode just puts up an alert: "There was an internal API error." 但是,这是一个很大的问题:当我尝试在iOS 5设备上安装应用程序时,Xcode只是发出警告:“存在内部API错误。”

I think there's a bug in iOS 5 and iOS 6, such that they don't ignore the forks that are from the future. 我认为iOS 5和iOS 6中存在一个错误,因此他们不会忽略未来的分叉。 The loader should simply ignore the forks it doesn't recognize. 加载器应该简单地忽略它无法识别的分叉。 But that's not the way it works. 但这不是它的工作方式。

Apple is never going to fix iOS 5. I thought Apple might work around the problem when the app is loaded onto a device: have Xcode strip the unneeded fork, and re-sign the (now modified) binary. Apple永远不会修复iOS 5.我认为当应用程序加载到设备上时Apple可能会解决这个问题:让Xcode剥离不需要的fork,然后重新签名(现在修改过的)二进制文件。 Similarly, downloading from iTunes could strip the unneeded fork and re-sign. 同样,从iTunes下载可能会删除不需要的分叉并重新签名。 But Apple is unlikely to do this: Apple wants everyone who can to upgrade to iOS7. 但苹果不太可能这样做:Apple希望每个人都可以升级到iOS7。 Apple solution for those who can't upgrade is: buy new hardware. 对于那些无法升级的人而言,Apple解决方案是:购买新硬件。

So, we're stuck. 所以,我们被困住了。 You can have a single title in the app store that supports 5&6, and issue an update that's for 7 that's fat armv7 and arm64, so your users who have iOS7 will get the fat one, and your users who have 5 or 6 will get the old one, but you can only do it once. 您可以在应用程序商店中拥有支持5和6的单个标题,并发出7个胖胖armv7和arm64的更新,因此拥有iOS7的用户将获得胖,而拥有5或6的用户将获得旧的,但你只能做一次。 Once you post the 7 update, you can never update the 5&6 update ever again. 发布7更新后,您再也无法更新5和6更新。

Is there a way around this? 有没有解决的办法? I want a single program that runs on Armv7 and Arm64, and iOS 5&6 for the armv7 side, iOS 7 for armv7 on harder that isn't arm64 and iOS 7 arm64 where its supported, How? 我想要一个在Armv7和Arm64上运行的程序,以及用于armv7方面的iOS 5和6,用于armv7的iOS 7更难以支持arm64和支持的iOS 7 arm64,如何?

Binaries with 64-bit slivers cannot be opened on iOS 5. It is an OS-level limitation, and there is no way around it. 在iOS 5上无法打开具有64位条带的二进制文件。这是操作系统级别的限制,并且没有办法解决它。 Generally, it should not be necessary to support iOS 5 any more, but I'm sure someone somewhere has a legitimate reason to support it, and hopefully they'll find this question. 一般来说,不再需要支持iOS 5,但我确信某个地方有人有正当理由支持它,希望他们能找到这个问题。

If you must support iOS 5, you have to remove the sliver for 64-bit. 如果您必须支持iOS 5,则必须删除64位的条子。 I This does not prevent your app from working on 64-bit systems. 我这并不妨碍您的应用程序在64位系统上运行。 It just makes it run as a 32-bit app. 它只是使它作为32位应用程序运行。 Most users won't even notice the difference. 大多数用户甚至都不会注意到差异。

As of this current Xcode version (Version 5.0 (5A1412)): 截至目前的Xcode版本(5.0版(5A1412)):

Note: A future version of Xcode will let you create a single app that supports the 32-bit runtime on iOS 6 and later, and that supports the 64-bit runtime on iOS 7. Apple Source 注意:未来版本的Xcode将允许您创建一个支持iOS 6及更高版本上的32位运行时的应用程序,并支持iOS 7上的64位运行时.Apple Source

Apple fixed this problem in iOS 5.1 so, if you set your min-deployment-target to 5.1, then you can make a 32/64 fat binary that will work in 5.1 on up. Apple在iOS 5.1中解决了这个问题,所以,如果你将min-deployment-target设置为5.1,那么你可以创建一个32/64胖的二进制文件,它可以在5.1上运行。 I wrote the original question before 5.1 came out. 我在5.1出来之前写了原始问题。

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

相关问题 iOS - ASM代码是否可以在armv7 / armv7s / arm64上运行? - iOS - Will ASM code run on armv7/armv7s/arm64? Lipo不为arm64,armv7创建 - Lipo in not creating for arm64, armv7 Armv7 + Arm64胖版与iPhone 4s不兼容 - Armv7 + Arm64 fat build is incompatible with iPhone 4s armv7,armv7s和arm64的ipa存档版本无法安装到iOS 5.1.1设备 - ipa archive build for armv7, armv7s and arm64 cannot be installed to iOS 5.1.1 devices Worklight 6.0.0.1 iOS Native Library仅适用于ARMv7而不适用于ARMv7和ARM64? - Worklight 6.0.0.1 iOS Native Library only for ARMv7 and not for ARMv7s and ARM64? 在Armv7,Arv7和arm64中使用Linphone - Use Linphone in Armv7s, Armv7 and arm64 我如何为armv6,armv7和i386编译静态库(fat) - How do i compile a static library (fat) for armv6, armv7 and i386 如何使用armv6,armv7和armv7s创建Fat Binary - How to create a Fat Binary with armv6,armv7 and armv7s 如何将libmms编译为适用于iPhone设备和模拟器的胖静态库(armv6,armv7和i386) - How to compile libmms to a fat static library for iPhone device and simulator(armv6,armv7 and i386) iPhone 5S特定错误:没有要编译的体系结构(ONLY_ACTIVE_ARCH = YES,活动arch = arm64,VALID_ARCHS = armv7 armv7s) - iPhone 5S Specific Error: No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=arm64, VALID_ARCHS=armv7 armv7s)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM