Skip to content

Instantly share code, notes, and snippets.

@zackslash
Created July 16, 2014 15:24
Show Gist options
  • Save zackslash/8f3989317507cca37995 to your computer and use it in GitHub Desktop.
Save zackslash/8f3989317507cca37995 to your computer and use it in GitHub Desktop.
Script to Build .framework bundle from .a library in Xcode
####
# Build a .framework bundle from an iOS library (.a) in Xcode
# Usage: Place this inside a run script in your project's "Build phases"
# Note: Script assumes that your .h, .a and .bundle are all in the same folder
####
####
# Your Vars Start
####
FRAMEWORK_NAME=MyFramework
FRAMEWORK_VERSION=A
RESOURCES_BUNDLE=Resources.bundle
# The source location of your library, Its where all your .h .a and .bundle should be.
SRC_LOCATION=${TARGET_BUILD_DIR}/../MyLibraryOut
# The name of your .a file, AKA your library's binary.
DOT_A_FILENAME=myProject-${CURRENT_PROJECT_VERSION}.a
# Location of where you would like your library to output
OUTPUT_LOCATION=${SRCROOT}/${FRAMEWORK_NAME}.framework
####
# Your Vars End
####
# remove old version
rm -rf "${OUTPUT_LOCATION}"
# Create framework folder structure
mkdir -p "${OUTPUT_LOCATION}"
mkdir -p "${OUTPUT_LOCATION}/Versions"
mkdir -p "${OUTPUT_LOCATION}/Versions/${FRAMEWORK_VERSION}"
mkdir -p "${OUTPUT_LOCATION}/Versions/${FRAMEWORK_VERSION}/Resources"
mkdir -p "${OUTPUT_LOCATION}/Versions/${FRAMEWORK_VERSION}/Headers"
# Create framework relative sym links.
ln -s "${FRAMEWORK_VERSION}" "${OUTPUT_LOCATION}/Versions/Current"
ln -s "Versions/Current/Headers" "${OUTPUT_LOCATION}/Headers"
ln -s "Versions/Current/Resources" "${OUTPUT_LOCATION}/Resources"
ln -s "Versions/Current/${FRAMEWORK_NAME}" "${OUTPUT_LOCATION}/${FRAMEWORK_NAME}"
# Copy headers, resources and binary files to their framework locations
cp -R "${SRC_LOCATION}/${DOT_A_FILENAME}" "${OUTPUT_LOCATION}/Versions/${FRAMEWORK_VERSION}/${FRAMEWORK_NAME}"
find ${SRC_LOCATION} -name "*.h" -exec cp {} ${OUTPUT_LOCATION}/Versions/${FRAMEWORK_VERSION}/Headers/ \;
cp -R "${SRC_LOCATION}/${RESOURCES_BUNDLE}" "${OUTPUT_LOCATION}/Versions/${FRAMEWORK_VERSION}/Resources"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment