Skip to content

Instantly share code, notes, and snippets.

@pxlshpr
Last active December 15, 2015 13:42
Show Gist options
  • Save pxlshpr/0f59a1782fc24dd5a375 to your computer and use it in GitHub Desktop.
Save pxlshpr/0f59a1782fc24dd5a375 to your computer and use it in GitHub Desktop.
Xcode Run Script – Create universal binary file for framework
#CONFIG=${CONFIGURATION}
CONFIG=Release
# Step 1. Make sure the output directory exists
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIG}-universal
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 2. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIG} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIG} -sdk iphonesimulator -arch x86_64 -arch i386 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 3. Copy the framework structure to the universal folder. Subsequently opy the files of the swiftmodule (in Modules directory) of -iphonesimulator to the swiftmodule of universal framework directory.
cp -R "${BUILD_DIR}/${CONFIG}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
cp -R "${BUILD_DIR}/${CONFIG}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIG}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIG}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# This next bit will copy the framework to a convenient location, so that we can be sure it is always up-to-date
FRAMEWORK_PATH="${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"
FRAMEWORKS_PATH="/Users/ahmed/Frameworks"
mkdir -p ${FRAMEWORKS_PATH}
cp -pr ${FRAMEWORK_PATH} ${FRAMEWORKS_PATH}
#open ${FRAMEWORKS_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment