Skip to content

Instantly share code, notes, and snippets.

@benjohnde
Last active August 18, 2017 08:16
Show Gist options
  • Save benjohnde/6129bd3862071c1aef46a6a88b152159 to your computer and use it in GitHub Desktop.
Save benjohnde/6129bd3862071c1aef46a6a88b152159 to your computer and use it in GitHub Desktop.
Use https://github.com/JDevlieghere/LibEBC to check for bitcode presence.
#!/bin/bash
# (0) project-related definitions
PROJECT_NAME="AlgoreKit"
BUILD_DIR="./build"
CONFIGURATION="Release"
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# (1) make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# (2) build device and simulator versions
xcodebuild -target "${PROJECT_NAME}" \
BITCODE_GENERATION_MODE=bitcode \
ONLY_ACTIVE_ARCH=NO \
-configuration ${CONFIGURATION} \
-sdk iphoneos \
BUILD_DIR="${BUILD_DIR}" \
BUILD_ROOT="${BUILD_ROOT}" \
clean build
xcodebuild -target \
"${PROJECT_NAME}"\
-configuration ${CONFIGURATION} \
-sdk iphonesimulator \
ONLY_ACTIVE_ARCH=NO \
BUILD_DIR="${BUILD_DIR}" \
BUILD_ROOT="${BUILD_ROOT}" \
clean build
# (3) copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
# (4) copy swiftmodules from simulator build as well
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/"
# (5) 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}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" \
"${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# (6) convenience step to open the universal folder in Finder
open "${UNIVERSAL_OUTPUTFOLDER}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment