Mik*_*ike 93
我已经能够使用App Store中的应用程序成功完成此操作.它支持从4.2到6.0的armv6,armv7和armv7s以及iOS版本.我已经证实它可以通过iPhone 5在旧设备(iPhone 3G,iPod touch 2g)上运行.
此方法需要同时安装Xcode 4.5和旧版Xcode.对于我的旧版本,我仍然使用4.3.2,但4.4应该也可以.
我有这个答案的截图,但Stack Overflow不会让我发布它们因为我是新的.:(
为armv6构建添加新的构建配置.我复制了Release配置并将其命名为Release_armv6.
为构建配置设置体系结构和有效体系结构.对于除Release_armv6之外的所有内容,请使用默认值.对于Release_armv6,手动将其设置为armv6. http://i.stack.imgur.com/h8Mpl.png
如果你使用Xcode 4.4及以下版本无法理解的iOS 6功能,你需要#ifdef这些用于你的armv6版本.在其他C标志和其他C++标志下的构建设置中,我将-DARMV6_ONLY添加到我的Release_armv6配置中.然后,无论代码使用新的iOS 6 API,我都会根据需要执行类似#ifndef ARMV6_ONLY/#endif的操作. http://i.stack.imgur.com/czF6J.png
添加新方案并将其设置为在所有情况下使用Release_armv6构建配置.
在Build Phases下,使用以下脚本添加Run Script Build Phase(将Shell设置为/ bin/csh).这就是魔术发生的地方.编辑"配置"部分:确定Release_armv6构建的完整路径,并将其替换为ARMV6_EXECUTABLE_PATH.还设置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"
Run Code Online (Sandbox Code Playgroud)
准备好创建发布版本时,请按以下顺序执行此操作:
关闭Xcode 4.5并打开Xcode 4.4或更低版本.选择你的armv6方案并构建它.
关闭Xcode 4.4或更低版本并打开Xcode 4.5.选择您的发布方案并构建它.
这就是它.检查构建输出以验证您是否拥有所需的内容 - 包含三个体系结构的可执行文件.运行脚本的最后一个输出应该告诉你.
如果有人有想法改善这一点,请随意.我想你可能会喜欢并在构建脚本中调用Xcode 4.4的"xcodebuild"命令,从而减少了在Xcode版本之间切换的需要.但这对我来说效果很好.;)
注意事项:
为了安全起见,您可能希望在旧版Xcode中编辑xib文件.到目前为止,似乎4.5向后兼容,但你永远不会知道.
实际上,您可能会考虑在旧Xcode中进行大部分开发,除了iOS 6特定的东西.取决于你最简单的事情.
ıɾu*_*uǝʞ 26
还有一种方法,因为gcc-4.2仍然支持armv6,它不需要你关闭Xcode 4.5打开以前的版本(用于编译,但不能在4.2设备上运行应用程序):
Archs:$(ARCHS_STANDARD_32_BIT)armv6
有效的架构: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
Build Rule名称匹配的源文件:*.[mc]将使用LLVM GCC 4.2它适用于静态库,但不适用于应用程序:
ld: file is universal (4 slices) but does not contain a(n) armv6 slice: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o for architecture armv6
lipo /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
编译项目并检查您的应用是否包含所有拱门:
$ file DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp: Mach-O universal binary with 3 architectures DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp (for architecture armv6): Mach-O executable arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp (for architecture armv7): Mach-O executable arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app/TestApp (for architecture cputype (12) cpusubtype (11)): Mach-O executable arm
请注意,dSYM文件还包含所有arch(对崩溃报告符号有用):
$ 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: Mach-O universal binary with 3 architectures DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (for architecture armv6): Mach-O dSYM companion file arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (for architecture armv7): Mach-O dSYM companion file arm DerivedData/TestApp/Build/Products/Debug-iphoneos/TestApp.app.dSYM/Contents/Resources/DWARF/TestApp (for architecture cputype (12) cpusubtype (11)): Mach-O dSYM companion file arm
我通过打开xcode 4.4.1然后Product- > 在iOS 4.2 2gen iPod touch上成功安装并启动了应用程序Run without building.
libarclite_iphoneos.a或libclang_rt.ios.a:ld: file is universal (2 slices) but does not contain a(n) armv6 slice: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a for architecture armv6
ld: file is universal (2 slices) but does not contain a(n) armv6 slice: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.1/libclang_rt.ios.a for architecture 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"类型的设备.但ls在DeviceSupport节目中:
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如何检测是否支持设备?
开幕式/Applications/Xcode.app/Contents/Developer//Platforms/iPhoneOS.platform/Developer//Library/PrivateFrameworks/DTDeviceKitBase.framework/DTDeviceKitBase与Hex Fiend(或其他十六进制编辑器),并取代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版本是在哪里定义的?
由于有一个4.2目录/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/,它应该已经被支持了......
试图iPhoneOS4.2.sdk从Xcode 4.4.1 复制到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/,但它不支持设备.
所以还没有找到如何在Xcode 4.5中添加4.2设备支持.有任何想法吗 ?
结论:在Xcode 4.5中编译armv6/7/7s是可能的.但是如果不启动Xcode 4.4,就无法在4.2 armv6设备上启动应用程序.
大更新:它适用于Xcode 4.5.2!
现在,子弹在Xcode 4.5.2中是绿色的:-)设备出现在"运行"按钮附近的下拉列表中.但是在尝试运行应用程序时,收到了消息:
Xcode cannot run using the selected device. Choose a destination with a supported architecture in order to run on this device.
只需将armv6添加到有效的架构中:-)
其他注意:Build Rule名称匹配的源文件*.[mc]可以使用LLVM GCC 4.2或Apple LLVM compiler 4.1,或Default compiler
谢谢你这个有用的脚本!
我成功地将整个帖子中的所有信息组合在一起,得到的完整脚本如下.此脚本需要同时支持Xcode 4.5.x和支持armv6的先前Xcode版本(例如,Xcode 4.4.1,安装在/ Applications/Xcode 4.4.1.app中)
该脚本不需要首先在xcode 4.4.x中编译,您只需启动最新的Xcode,选择Release配置和构建.(Release-armv6配置应该像Mike的原始帖子中提到的那样定义).
它将产生与armv6 armv7和armv7s兼容的.app
感谢Mike的原始剧本!
#################
# 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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
38611 次 |
| 最近记录: |