Skip to content

Instantly share code, notes, and snippets.

@jbuda
Created March 31, 2014 08:44
Show Gist options
  • Save jbuda/9888066 to your computer and use it in GitHub Desktop.
Save jbuda/9888066 to your computer and use it in GitHub Desktop.
Compiling 32/64 bit for devices and simulators for Objective-C and XCode
# folder vars
FOLDERNAME=${PROJECT_NAME}
LIBRARYNAME="lib${PROJECT_NAME}.a"
OUTPUTFOLDER=${SRCROOT}/build/${FOLDERNAME}
# make sure the output directory exists
mkdir -p "${OUTPUTFOLDER}"
# device / simulator builds
xcodebuild -project "${PROJECT_NAME}.xcodeproj" -configuration "Release" -sdk "iphoneos7.1" clean build ARCHS="armv7 armv7s" IPHONEOS_DEPLOYMENT_TARGET="5.0" TARGET_BUILD_DIR="${BUILD_DIR}/build-arm" BUILT_PRODUCTS_DIR="${BUILD_DIR}/build-arm"
xcodebuild -project "${PROJECT_NAME}.xcodeproj" -configuration "Release" -sdk "iphoneos7.1" clean build ARCHS="arm64" IPHONEOS_DEPLOYMENT_TARGET="7.0" TARGET_BUILD_DIR="${BUILD_DIR}/build-arm64" BUILT_PRODUCTS_DIR="${BUILD_DIR}/build-arm64"
xcodebuild -project "${PROJECT_NAME}.xcodeproj" -configuration "Release" -sdk "iphonesimulator7.0" clean build ARCHS="i386" IPHONEOS_DEPLOYMENT_TARGET="5.0" TARGET_BUILD_DIR="${BUILD_DIR}/build-i386" BUILT_PRODUCTS_DIR="${BUILD_DIR}/build-i386"
xcodebuild -project "${PROJECT_NAME}.xcodeproj" -configuration "Release" -sdk "iphonesimulator7.0" clean build ARCHS="x86_64" VALID_ARCHS="x86_64" IPHONEOS_DEPLOYMENT_TARGET="7.0" TARGET_BUILD_DIR="${BUILD_DIR}/build-x86_64" BUILT_PRODUCTS_DIR="${BUILD_DIR}/build-x86_64"
# create universal library
lipo -create "${BUILD_DIR}/build-arm/${LIBRARYNAME}" "${BUILD_DIR}/build-arm64/${LIBRARYNAME}" "${BUILD_DIR}/build-i386/${LIBRARYNAME}" "${BUILD_DIR}/build-x86_64/${LIBRARYNAME}" -output "${OUTPUTFOLDER}/${LIBRARYNAME}"
# copy the header files
cp -R "${BUILD_DIR}/build-arm/include" "${OUTPUTFOLDER}/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment