我知道这是不可能的,苹果公司早已计划好了这一点,以此来迫使用户升级设备。但我想知道是否有某些绕过方法或者黑客技巧可以实现呢?客户坚持我们仍应该支持armv6,因为仍有“大量”的应用程序用户。
我知道一个叫做lipo
的命令可以合并静态库文件,我也在某个地方读到可以使用它来合并ipa文件,但我不确定具体该如何操作。我已经在Google和这个网站上进行了几次搜索,但很难找到确切的答案。
#
# 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"
当您准备创建发布版本时,请按照以下顺序执行:
关闭Xcode 4.5并打开Xcode 4.4或更低版本。选择您的armv6方案并进行构建。
关闭Xcode 4.4或更低版本并打开Xcode 4.5。选择您的发布方案并进行构建。
就是这样。检查构建输出以验证您是否得到了所需的内容-一个包含三种架构的可执行文件。运行脚本的最后一个输出应告诉您这一点。
如果有任何改进的想法,请随意提出。我想您可能可以通过在构建脚本中调用Xcode 4.4的“xcodebuild”命令来变得更加复杂,从而消除完全切换Xcode版本的需要。但对我来说,这已经足够好了。;)
注意事项:
为了安全起见,您可能希望在较旧的Xcode版本中编辑您的xib文件。到目前为止,似乎4.5向下兼容,但您永远不知道。
实际上,除了iOS 6特定的内容之外,您可能考虑在旧版本的Xcode中进行大部分开发。这取决于您最容易处理什么。
还有另外一种方法,因为gcc-4.2仍支持armv6,在不需要关闭Xcode 4.5的情况下就可以完成编译(但不能在4.2设备上运行app):
Archs: $(ARCHS_STANDARD_32_BIT) armv6
Valid Architectures: armv6 armv7 armv7s
那么,如果您构建项目,您将会看到警告信息:
warning: no rule to process file '$(PROJECT_DIR)/App/AppDelegate.m' of type sourcecode.c.objc for architecture armv6 warning: no rule to process file '$(PROJECT_DIR)/App/SomeFile.c' of type sourcecode.c.c for architecture armv6
这适用于静态库,但不适用于应用程序:
ld: 文件是通用的(4个片段),但不包含armv6架构:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.olipo /path/to-4.4/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/crt1.3.1.o -extract armv6 -output /tmp/crt1.3.1-armv6.o lipo /Applications/Xcode.app/Contents//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o /tmp/crt1.3.1-armv6.o -create -output /tmp/crt1.3.1-armv677s.o mv /Applications/Xcode.app/Contents//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o /Applications/Xcode.app/Contents//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o.bkp mv /tmp/crt1.3.1-armv677s.o /Applications/Xcode.app/Contents//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
编译您的项目并检查您的应用程序是否包含所有archs:
$ file DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp:具有3个体系结构的Mach-O通用二进制文件 DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp(针对armv6体系结构):Mach-O可执行文件 DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp(针对armv7体系结构):Mach-O可执行文件 DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp(针对cputype(12)cpusubtype(11)体系结构):Mach-O可执行文件
请注意,dSYM文件也包含所有archs(用于崩溃报告符号化):
$ file DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp: 一份带有3种架构的Mach-O通用二进制文件 DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (用于架构armv6): Mach-O dSYM附属文件 arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (用于架构armv7): Mach-O dSYM附属文件 arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (用于cputype(12) cpusubtype(11)架构): Mach-O dSYM附属文件 arm
我成功地在一个iOS 4.2第二代iPod touch上,通过打开Xcode 4.4.1,然后选择“Product” -> “Run without building”,安装并启动了应用程序。
当你“Archive”你的产品时,你可能会再次遇到Apple Mach-O链接器错误,这次涉及其他文件,如“libarclite_iphoneos.a”或“libclang_rt.ios.a”: ld:文件是通用的(2个片段),但不包含armv6片段:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a 适用于架构armv6 ld:文件是通用的(2个片段),但不包含armv6片段:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.1/libclang_rt.ios.a 适用于架构armv6
对这些文件使用crt1.3.1.o的过程也适用,并且将修复错误,使Xcode能够成功归档您的项目:您可以使用“ld”打印的路径找到文件并使用“lipo”连接armv6片段;只需记住,以前版本的Xcode中的libclang_rt.ios.a没有在“Xcode.app/[...] /usr/lib/clang/4.1”中,而是在“Xcode.app/[...]/usr/lib/clang/4.0”中。
我已经成功地归档了该文件,使用临时分发配置文件部署并在iPhone 3G(4.2.1)和iPhone 3GS(6.0)上测试。
最后一个问题:我们无法启动应用程序。在“Organizer”中,出现以下消息:“不支持此版本的Xcode的“iPhone 3G”类型设备。”但在DeviceSupport
中的ls
输出如下:ls /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ 4.2 4.3 5.0 5.1 6.0 (10A403)
Xcode 4.4.1
中的4.2
目录与当前版本中无差异。问题是:Xcode 如何检测设备是否受支持?
使用
Hex Fiend
(或其他十六进制编辑器)打开/Applications/Xcode.app/Contents/Developer//Platforms/iPhoneOS.platform/Developer//Library/PrivateFrameworks/DTDeviceKitBase.framework/DTDeviceKitBase
,将 ASCII 的4.3
替换为4.2
就可以消除错误消息,并列出已安装在设备上的应用程序(但设备列表中的设备圆点仍然是红色的)。接下来,我们需要编辑
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks//DTDeviceKit.framework/Versions/Current/DTDeviceKit
,将:
Expired.deviceArchitecture.iPhone1,1.iPhone1,2.iPod1,1.iPod2,1.iPod2,2.armv6
替换为:
Expired.deviceArchitecture.iPhone0,1.iPhone0,2.iPod0,1.iPod0,1.iPod0,2.armv5
然后我们在组织者中看到了橙色的圆点(Xcode 4.5.1):
The version of iOS on “iPhone” is too old for use with this version of the iOS SDK. Please restore the device to a version of the OS listed below.
OS Installed on iPhone 4.2.1 (8C148)
Xcode Supported iOS Versions 6.0 (10A403) 5.1 5.0 4.3现在问题是:Xcode 支持的 iOS 版本在哪里定义?
因为在
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
中存在一个4.2
目录,所以应该已经支持它了......尝试将 Xcode 4.4.1 中的
iPhoneOS4.2.sdk
拷贝到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
,但没有使设备受支持。因此,尚未找到如何在 Xcode 4.5 中添加 4.2 设备支持的方法。有什么想法吗?
结论:在 Xcode 4.5 中编译支持 armv6/7/7s 的应用程序是可能的。但是,在不启动 Xcode 4.4 的情况下无法在 armv6 的 4.2 设备上启动应用程序。
重要更新:现已兼容Xcode 4.5.2!
现在,在Xcode 4.5.2中子弹变成了绿色 :-) 设备出现在“运行”按钮附近的下拉列表中。 但是,在尝试运行应用程序时,会收到以下消息:
Xcode不能使用所选设备运行。 选择支持的架构目标以便在此设备上运行。只需将armv6添加到有效架构中即可 :-)
其他注意事项:与名称匹配的源文件的Build Rule可以使用LLVM GCC 4.2或Apple LLVM编译器4.1,或默认编译器
Default compiler
#################
# Configuration #
#################
# Change this to the full path where Xcode 4.4 (or below) puts your armv6 output
setenv ARMV6_OUTPUT_PATH "$BUILD_ROOT/Release-armv6-iphoneos/"
setenv ARMV6_EXECUTABLE_PATH "$ARMV6_OUTPUT_PATH$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"
#log file for armv6 build
echo "------------------------- BUILDING ARMV6 NOW -------------------------"
setenv LOGFILE "$BUILD_ROOT/buildarmv6.txt"
setenv CONFIGURATION_ARMV6 "${CONFIGURATION}-armv6"
#build armv6 version
echo "Building $FULL_PRODUCT_NAME armv6 CONFIG=$CONFIGURATION-armv6 target=$TARGETNAME"
"/Applications/Xcode 4.4.1.app/Contents/Developer/usr/bin/xcodebuild" -project "${PROJECT_FILE_PATH}" -target "${TARGETNAME}" -sdk "${PLATFORM_NAME}" -configuration "$CONFIGURATION-armv6" CONFIGURATION_BUILD_DIR="$ARMV6_OUTPUT_PATH" >> "$LOGFILE"
echo "---------------------------- ARMV6 BUILT -------------------------"
# to check for armv6 build errors
open "$LOGFILE"
# 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"
echo "------------------------- CHECK ARMV6 ARMV7 ARMV7S ARE MENTIONED BELOW -------------------------"
lipo -info "$FINAL_PATH"
echo "------------------------------------------------------------------------------------------------"
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"
setenv LOGFILE "/Users/xyz/Desktop/buildarmv6.txt"
setenv CONFIGURATION_ARMV6 "${CONFIGURATION}_armv6"
echo "Building $FULL_PRODUCT_NAME armv6 CONFIG=$CONFIGURATION_ARMV6 target=$TARGETNAME"
"/Applications/Xcode 4.4.1.app/Contents/Developer/usr/bin/xcodebuild" -project "${PROJECT_FILE_PATH}" -target "${TARGETNAME}" -sdk "${PLATFORM_NAME}" -configuration "$CONFIGURATION_ARMV6" >> "$LOGFILE"
echo "Built armv6"
open "$LOGFILE" # to check for armv6 build errors
感谢Mike提供这个有用的教程和脚本。正如Piotr在评论中提到的那样,如果您从Xcode运行归档命令,则该脚本会失败,因为它使用另一个构建目录进行归档。
下面是我对脚本的修改,以使其适用于普通发布构建和特定归档构建。
它假定按照Mike的原始说明先运行armv6构建。它使用bash语法,因为我更容易剥离公共基础构建目录。因此,这意味着将原始脚本翻译为bash,只需要用export替换setenv并更改if语句语法。
# Find the common base directory for both build
XCODE_BUILD=${BUILD_ROOT%%/Build*}
# Change this to the full path where Xcode 4.4 (or below) puts your armv6 output, using the previously derived base
export ARMV6_EXECUTABLE_PATH="$XCODE_BUILD/Build/Products/Release_armv6-iphoneos/$EXECUTABLE_PATH"
苹果已停止接受支持iOS5及以下设备且包含iPhone 5启动图的构建。这是我提交的最后一个使用Xcode 4.4.1构建的版本的电子邮件:
亲爱的开发者,
我们在您最近的交付中发现了一个或多个问题。为了处理您的交付,必须纠正以下问题:
无效的启动图像 - 您的应用程序包含一个大小修饰符的启动图像,该修饰符仅适用于使用iOS 6.0 SDK或更高版本构建的应用程序。
一旦这些问题得到解决,转到版本详细信息页面,然后单击“准备上传二进制文件”。继续提交过程,直到应用状态为“等待上传”。然后,您可以交付已更正的二进制文件。
问候,
App Store团队