如何在 xcode 4.5 中同时支持 armv6 和 armv7s 发布版本 [英] How to support both armv6 and armv7s for release build in xcode 4.5

查看:32
本文介绍了如何在 xcode 4.5 中同时支持 armv6 和 armv7s 发布版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是不可能的,Apple 计划以这种方式强制用户升级他们的设备.但我只想知道是否有一些解决方法或技巧可以做到这一点?客户坚持认为我们仍然应该支持 armv6,因为应用用户的比例仍然很大".

I know that this is not possible and Apple planned it this way to force the users to upgrade their devices. But I just want to know if there is some workaround or hacks in able to do this? The client insists that we should still support armv6 because of a still "large" percentage of the app users.

我知道一个名为 lipo 的命令来合并静态库,我在某处读到我们也可以用它来合并 ipa 文件,但我不确定它是如何完成的.我已经在谷歌和这个网站上搜索了几次,但很难找到具体的答案.

I know a command called lipo to merge static libraries and I read somewhere that we can also use it to merge ipa files but I'm not sure how its exactly done. I did a couple of searching around already on google and this site, buts its hard to find a concrete answer.

推荐答案

我已经能够使用 App Store 中的应用成功地做到这一点.它支持 armv6、armv7 和 armv7s 以及从 4.2 到 6.0 的 iOS 版本.我已经验证它可以在旧设备(iPhone 3G、iPod touch 2g)上运行到 iPhone 5.

I've been able to do this successfully with my app that's in the App Store. It supports armv6, armv7, and armv7s and iOS versions from 4.2 to 6.0. I've verified that it runs on older devices (iPhone 3G, iPod touch 2g) all the way through the iPhone 5.

此方法需要同时安装 Xcode 4.5 和旧版本的 Xcode.我的旧版本仍然使用 4.3.2,但 4.4 应该也可以使用.

This method requires having both Xcode 4.5 and an older version of Xcode installed simultaneously. I'm still on 4.3.2 for my older version, but 4.4 should work as well.

我有这个答案的截图,但 Stack Overflow 不允许我发布它们,因为我是新手.:(

I had screenshots for this answer, but Stack Overflow won't let me post them because I'm new. :(

  1. 为您的 armv6 构建添加新的构建配置.我复制了 Release 配置并将其命名为 Release_armv6.

  1. Add a new build configuration for your armv6 build. I duplicated the Release config and named it Release_armv6.

为您的构建配置设置架构和有效架构.对于除 Release_armv6 之外的所有版本,使用默认值.对于 Release_armv6,手动将其设置为 armv6.http://i.stack.imgur.com/h8Mpl.png

Set the Architectures and Valid Architectures for your build configurations. For all but Release_armv6, use the default. For Release_armv6, manually set it to armv6. http://i.stack.imgur.com/h8Mpl.png

如果您使用的是 Xcode 4.4 及更低版本无法理解的 iOS 6 功能,则需要为 armv6 构建 #ifdef 这些功能.在其他 C 标志和其他 C++ 标志下的构建设置中,我将 -DARMV6_ONLY 添加到我的 Release_armv6 配置中.然后在代码使用新的 iOS 6 API 的任何地方,我都会根据需要执行 #ifndef ARMV6_ONLY/#endif 之类的操作.http://i.stack.imgur.com/czF6J.png

If you're using iOS 6 features that Xcode 4.4 and below won't understand, you'll need to #ifdef these out for your armv6 build. In Build Settings under Other C Flags and Other C++ Flags I added -DARMV6_ONLY to my Release_armv6 config. Then wherever the code uses a new iOS 6 API, I do something like #ifndef ARMV6_ONLY / #endif as appropriate. http://i.stack.imgur.com/czF6J.png

添加一个新方案并将其设置为在所有情况下都使用 Release_armv6 构建配置.

Add a new scheme and set it to use the Release_armv6 build configuration in all cases.

在构建阶段下,使用以下脚本添加运行脚本构建阶段(将 Shell 设置为 /bin/csh).这就是魔法发生的地方.编辑配置部分: 确定 Release_armv6 构建的完整路径并将其替换为 ARMV6_EXECUTABLE_PATH.还要设置 MINIMUM_OS.

Under Build Phases, add a Run Script Build Phase with the following script (set the Shell to /bin/csh). This is where the magic happens. Edit the Configuration section: Determine your full path to the Release_armv6 build and substitute it for ARMV6_EXECUTABLE_PATH. Also set MINIMUM_OS.



    #
    # Script to add armv6 architecture to iOS executable built with Xcode 4.5
    #

    #################
    # Configuration #
    #################
    # Change this to the full path where Xcode 4.4 (or below) puts your armv6 output
    setenv ARMV6_EXECUTABLE_PATH "$BUILD_ROOT/Release_armv6-iphoneos/$EXECUTABLE_PATH"

    # Your "real" minimum OS version since Xcode 4.5 wants to make it iOS 4.3
    # Must be 4.2 or below if you are supporting armv6...
    setenv MINIMUM_OS 4.2
    #####################
    # End configuration #
    #####################


    # For debugging
    echo CURRENT_ARCH = $CURRENT_ARCH
    echo CONFIGURATION = $CONFIGURATION

    # Don't need to do this for armv6 (built in older Xcode), simulator (i386), or debug build
    if ("$CURRENT_ARCH" == "armv6") exit 0
    if ("$CURRENT_ARCH" == "i386") exit 0
    if ("$CONFIGURATION" != "Release" && "$CONFIGURATION" != "Beta Test") exit 0

    # Paths
    setenv LIPO_PATH "$CODESIGNING_FOLDER_PATH/${EXECUTABLE_NAME}.lipo"
    setenv FINAL_PATH "$CODESIGNING_FOLDER_PATH/$EXECUTABLE_NAME"
    setenv FULL_INFO_PLIST_PATH "$CONFIGURATION_BUILD_DIR/$INFOPLIST_PATH"

    # Debug / sanity check
    lipo -info "$FINAL_PATH"
    ls -l "$ARMV6_EXECUTABLE_PATH"

    # Make sure something exists at $LIPO_PATH even if the next command fails
    cp -pv "$FINAL_PATH" "$LIPO_PATH"

    # If rebuilding without cleaning first, old armv6 might already be there so remove it
    # If not, lipo won't output anything (thus the cp command just above)
    lipo -remove armv6 -output "$LIPO_PATH" "$FINAL_PATH"

    # Add armv6 to the fat binary, show that it worked for debugging, then remove temp file
    lipo -create -output "$FINAL_PATH" "$ARMV6_EXECUTABLE_PATH" "$LIPO_PATH"
    lipo -info "$FINAL_PATH"
    rm -f "$LIPO_PATH"

    # Change Info.plist to set minimum OS version to 4.2 (instead of 4.3 which Xcode 4.5 wants)
    /usr/libexec/PlistBuddy -c "Set :MinimumOSVersion $MINIMUM_OS" "$FULL_INFO_PLIST_PATH"
    plutil -convert binary1 "$FULL_INFO_PLIST_PATH"

构建过程

当您准备好创建发布版本时,请按以下顺序进行:

Build Process

When you're ready to create a release build, do it in the following order:

  1. 关闭 Xcode 4.5 并打开 Xcode 4.4 或更低版本.选择您的 armv6 方案并构建它.

  1. Close Xcode 4.5 and open Xcode 4.4 or below. Select your armv6 scheme and build it.

关闭 Xcode 4.4 或更低版本并打开 Xcode 4.5.选择您的发布方案并构建它.

Close Xcode 4.4 or below and open Xcode 4.5. Select your Release scheme and build it.

差不多就是这样.检查构建输出以验证您是否获得了所需的内容 - 一个包含三种架构的可执行文件.运行脚本的最后输出应该告诉你这一点.

That's pretty much it. Check the build output to verify that you got what you want - an executable with three architectures in it. The last output from the run script should tell you this.

如果有人对此有改进的想法,请随意.我想您可能会喜欢并从构建脚本中调用 Xcode 4.4 的xcodebuild"命令,从而完全减少在 Xcode 版本之间切换的需要.但这对我来说已经足够了.;)

If anyone has ideas to improve this, please feel free. I imagine you might be able to get fancy and call Xcode 4.4's "xcodebuild" command from within the build script, alleviating the need to switch between Xcode versions at all. But this works well enough for me. ;)

注意事项:

  • 为了安全起见,您可能需要在旧版本的 Xcode 中编辑您的 xib 文件.到目前为止,4.5 似乎向后兼容,但您永远不知道.

  • Just to be safe, you might want to edit your xib files in the older version of Xcode. So far it seems like 4.5 is backwards compatible, but you never know.

实际上,您可能会考虑在旧版 Xcode 中完成大部分开发工作,iOS 6 特定的内容除外.取决于对您来说最简单的方法.

In fact, you might consider just doing most of your development, except for iOS 6-specific stuff, in the older Xcode. Depends on whatever's easiest for you.

这篇关于如何在 xcode 4.5 中同时支持 armv6 和 armv7s 发布版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆