Skip to content

Instantly share code, notes, and snippets.

@sponno
Last active December 9, 2021 09:03
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save sponno/7228256 to your computer and use it in GitHub Desktop.
Save sponno/7228256 to your computer and use it in GitHub Desktop.
Xcode build lipo script
# define output folder environment variable
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# Step 1. Build Device and Simulator versions
xcodebuild -target ${PROJECT_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}"
BUILD_ROOT="${BUILD_ROOT}" xcodebuild -target ${PROJECT_NAME} -configuration ${CONFIGURATION} -sdk iphonesimulator -arch i386 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 2. Create universal binary file using lipo
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/lib${PROJECT_NAME}.a" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/lib${PROJECT_NAME}.a" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a"
# Last touch. copy the header files. Just for convenience
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/include" "${UNIVERSAL_OUTPUTFOLDER}"
@KiranPanesar
Copy link

Looks like you need to append a $ to some of {PROJECT_NAME} in lines 5 and 6?

@sponno
Copy link
Author

sponno commented May 29, 2014

Thanks, have added the $. Good spotting.

@ThinkChaos
Copy link

Also you should double quote every single variable just in case.
My project has a space in it's name. It's a good thing I know shell scripts because this can cause a major headache!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment