Skip to content

Instantly share code, notes, and snippets.

@GuanshanLiu
Created December 28, 2012 07:12
Show Gist options
  • Save GuanshanLiu/4395292 to your computer and use it in GitHub Desktop.
Save GuanshanLiu/4395292 to your computer and use it in GitHub Desktop.
armv6 support for XCode 4.5 and above
# Modified from http://stackoverflow.com/questions/12619124/how-to-support-both-armv6-and-armv7s-for-release-build-in-xcode-4-5/12678077#12678077
# Thanks Mike, Jerome, Max_B for their contributions
#################
# Configuration #
#################
# 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
export ARMV6_OUTPUT_PATH="$XCODE_BUILD/Build/Products/Release-armv6-iphoneos/"
export 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 3.1
#####################
# 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" ]
then
exit 0
fi
if [ [ ! "$CONFIGURATION" = "Release" ] && [ ! "$CONFIGURATION" = "Beta Test" ] ]
then
exit 0
fi
# Paths
export LIPO_PATH="$CODESIGNING_FOLDER_PATH/${EXECUTABLE_NAME}.lipo"
export FINAL_PATH="$CODESIGNING_FOLDER_PATH/$EXECUTABLE_NAME"
export FULL_INFO_PLIST_PATH="$CONFIGURATION_BUILD_DIR/$INFOPLIST_PATH"
#log file for armv6 build
echo "------------------------- BUILDING ARMV6 NOW -------------------------"
export LOGFILE="$BUILD_ROOT/buildarmv6.txt"
export 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment