public
Last active

Make a simulator+device .a file with headers

  • Download Gist
makefatlib.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
# http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4
 
TARGET_NAME=<< name of your target or an environment variable >>
 
CONFIGURATION=Release
DEVICE=iphoneos
SIMULATOR=iphonesimulator
FAT=universal
OUTPUT=build
LIBRARY_NAME=lib${TARGET_NAME}.a
HEADERS_DIR_NAME=headers
 
for sdk in ${DEVICE} ${SIMULATOR}
do
xcodebuild -sdk $sdk -configuration ${CONFIGURATION} -target ${TARGET_NAME} -verbose
done
 
device_output=${OUTPUT}/${CONFIGURATION}-${DEVICE}
simulator_output=${OUTPUT}/${CONFIGURATION}-${SIMULATOR}
fatlib_output=${OUTPUT}/${CONFIGURATION}-${FAT}
 
rm -rf "${fatlib_output}"
mkdir -p "${fatlib_output}"
lipo -create -output "${fatlib_output}/${LIBRARY_NAME}" "${device_output}/${LIBRARY_NAME}" "${simulator_output}/${LIBRARY_NAME}"
 
headers_dir="${fatlib_output}/${HEADERS_DIR_NAME}"
mkdir -p "${headers_dir}"
cp ${TARGET_NAME}/*.h "${headers_dir}"
 
open "${fatlib_output}"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.