Skip to content

Instantly share code, notes, and snippets.

@gauravkeshre
Last active March 29, 2018 07:30
Show Gist options
  • Save gauravkeshre/a6b7bfe411b3dd6fd3c13ca00da72be1 to your computer and use it in GitHub Desktop.
Save gauravkeshre/a6b7bfe411b3dd6fd3c13ca00da72be1 to your computer and use it in GitHub Desktop.
iOS Cocoa Touch Static Library Aggregate Script

iOS Cocoa Touch Static Library Aggregate Script

What

For an framework to be compatible with various devices it has to be compiled for them specifically, This script does those tasks in single shot.

How

Install Script

Build Settings

  1. Select Target > Build Phases
  2. + > New Run Script Phase
  3. copy and paste this script in the script area.

Source

https://medium.com/@imsantoshk/ios-static-library-7c62bb984e6

#fat library path..
FAT_LIBRARY_PATH=${PROJECT_DIR}/build/${CONFIGURATION}-fatLib
TARGET="BootstrapExtensions"
#generates library for simulator target
xcodebuild -target ${TARGET} -configuration ${CONFIGURATION} -sdk iphonesimulator -arch i386 BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
#generates library for device target
xcodebuild -target ${TARGET} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}"
#Creates directory for fat-library
mkdir -p "${FAT_LIBRARY_PATH}”
#Creates fat library
lipo -create -output "${FAT_LIBRARY_PATH}/lib${PROJECT_NAME}.a" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/lib${PROJECT_NAME}.a" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a"
#copies header files
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/include" "${FAT_LIBRARY_PATH}/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment