Skip to content

Instantly share code, notes, and snippets.

@eoghain
Last active August 29, 2015 14:24
Show Gist options
  • Save eoghain/1a62eed3c7375006253e to your computer and use it in GitHub Desktop.
Save eoghain/1a62eed3c7375006253e to your computer and use it in GitHub Desktop.
Script to use in the Build Phases to create frameworks for simulator and device.
################
# Creating usable frameworks:
#
# 1. Install this script in your frameworks Build Phases as the last item
# 2. Build for the simulator
# 3. Archive for device
# 4. Package contents of _Archive directory
#
# Using created framework
#
# 1. Put packaged contents from #4 above into your project directory (same directory where your .xcodeproj lives). Will create Debug and Release folders.
# 2. In the Build Settings panel for the project/target (set to All and not Basic), add to the Runpath Search Paths and Framework Search Paths $(PROJECT_DIR)/MYFramework/$(CONFIGURATION)
# 3. Navigate to the General section of your project Target and add the desired Frameworks to the “Embedded Binaries” section. Add the binaries that are found in MYFramework/Release.This should automatically add them to the “Linked Frameworks and Libraries” below. Note: ensure that they aren’t duplicated in the “Linked Frameworks and Libraries” section!
#
################
set -e
DEVICE_BIN="${OBJROOT}/UninstalledProducts/${TARGET_NAME}.framework"
SIMULATOR_BIN="${SYMROOT}/../../../../Products/Debug-iphonesimulator/${TARGET_NAME}.framework"
ARCHIVE_PATH="${SRCROOT}/_Archive"
rm -rf "${ARCHIVE_PATH}"
mkdir "${ARCHIVE_PATH}"
if [ "${CONFIGURATION}" = "Release" ]; then
if [ -d "${DEVICE_BIN}" ]; then
DEVICE_PATH="${ARCHIVE_PATH}/Release"
mkdir "${DEVICE_PATH}"
cp -r "${DEVICE_BIN}" "${DEVICE_PATH}"
if [ -d "${SIMULATOR_BIN}" ]; then
SIMULATOR_PATH="${ARCHIVE_PATH}/Debug"
mkdir "${SIMULATOR_PATH}"
cp -r "${DEVICE_BIN}" "${SIMULATOR_PATH}"
lipo -create "${DEVICE_BIN}/${TARGET_NAME}" "${SIMULATOR_BIN}/${TARGET_NAME}" -output "${SIMULATOR_PATH}/${TARGET_NAME}.framework/${TARGET_NAME}"
fi
fi
fi
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment