Skip to content

Instantly share code, notes, and snippets.

@jacobvanorder
Last active November 21, 2016 10:45
Show Gist options
  • Save jacobvanorder/5eb6515b8e4670c7e293 to your computer and use it in GitHub Desktop.
Save jacobvanorder/5eb6515b8e4670c7e293 to your computer and use it in GitHub Desktop.
Bash Shell Script for Xcode Aggregate Target for new Xcode 6 Framework/Module
#Thanks to http://spin.atomicobject.com/2011/12/13/building-a-universal-framework-for-ios/ for the start
#To get this to work with a Xcode 6 Cocoa Touch Framework, create Framework
#Then create a new Aggregate Target. Throw this script into a Build Script Phrase on the Aggregate
#Tip: if you want the resulting framework to be the same name as your Framework, change the Aggregate's product name
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PRODUCT_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PRODUCT_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${PRODUCT_NAME}.framework"
#build both frameworks
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphonesimulator -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator
xcodebuild -project ${PROJECT_NAME}.xcodeproj -sdk iphoneos -target ${PROJECT_NAME} -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos
#create directory for universal
mkdir "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${FRAMEWORK}"
#copy the headers
cp -r "${DEVICE_LIBRARY_PATH}/Headers" "${FRAMEWORK}/Headers"
#copy all of the other files associated
cp "${DEVICE_LIBRARY_PATH}/Info.plist" "${FRAMEWORK}"
cp -r "${DEVICE_LIBRARY_PATH}/Modules" "${FRAMEWORK}/Modules"
cp "${DEVICE_LIBRARY_PATH}/ResourceRules.plist" "${FRAMEWORK}"
#make fat binary
lipo "${SIMULATOR_LIBRARY_PATH}/${PRODUCT_NAME}" "${DEVICE_LIBRARY_PATH}/${PRODUCT_NAME}" -create -output "${FRAMEWORK}/${PRODUCT_NAME}"
#copy the result to your desktop so you don't have to hunt for it in DerivedData
cp -r "${FRAMEWORK}" "${HOME}/Desktop/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment