Created
February 19, 2011 17:17
-
-
Save jbenet/835197 to your computer and use it in GitHub Desktop.
setup a static framework from iphoneos and iphonesimulator static libs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Framework.sh -- static iOS framwork packager | |
# | |
# This script combines two static libs (iphoneos and iphonesimulator) into one, | |
# and then packages it into a static, app-store friendly, framework. | |
# A chosen configuration is also packaged into a tarball for easy releases :) | |
# | |
# Original Script by Pete Goodliffe | |
# from http://accu.org/index.php/journals/1594 | |
# | |
# modified by Juan Batiz-Benet (http://github.com/jbenet) | |
# | |
# | |
################################################################################ | |
# CONFIG: | |
LIB_NAME=MyFramework | |
FRAMEWORK_NAME=$LIB_NAME | |
FRAMEWORK_VERSION=A | |
FRAMEWORK_CURRENT_VERSION=1 | |
FRAMEWORK_COMPATIBILITY_VERSION=1 | |
FRAMEWORK_TARBALL_CONFIGURATION=Release | |
FRAMEWORK_TARBALL_PATH=release | |
FRAMEWORK_TARBALL=$FRAMEWORK_NAME.tar.gz | |
################################################################################ | |
CMD="$0: [$CONFIGURATION]" | |
# Where we'll put the build framework. | |
# The script presumes we're in the project root | |
# directory. Xcode builds in "build" by default | |
FRAMEWORK_BUILD_PATH="build/$CONFIGURATION-Framework" | |
FRAMEWORK_DIR="$FRAMEWORK_BUILD_PATH/$FRAMEWORK_NAME.framework" | |
echo "$CMD building $FRAMEWORK_DIR" | |
# Clean any existing framework that might be there already | |
echo "$CMD Cleaning framework structure..." | |
[ -d "$FRAMEWORK_DIR" ] && \ | |
rm -rf $FRAMEWORK_DIR/* | |
# Build the canonical Framework bundle directory | |
# structure | |
echo "$CMD Setting up directories..." | |
mkdir -p $FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Resources | |
mkdir -p $FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Headers | |
echo "$CMD Creating symlinks..." | |
ln -s $FRAMEWORK_VERSION $FRAMEWORK_DIR/Versions/Current | |
ln -s Versions/Current/Headers $FRAMEWORK_DIR/Headers | |
ln -s Versions/Current/Resources $FRAMEWORK_DIR/Resources | |
ln -s Versions/Current/$FRAMEWORK_NAME $FRAMEWORK_DIR/$FRAMEWORK_NAME | |
# Check that this is what your static libraries | |
# are called | |
FRAMEWORK_INPUT_ARM_FILES="build/$CONFIGURATION-iphoneos/lib$LIB_NAME.a" | |
FRAMEWORK_INPUT_I386_FILES="build/$CONFIGURATION-iphonesimulator/lib$LIB_NAME.a" | |
# The trick for creating a fully usable library is | |
# to use lipo to glue the different library | |
# versions together into one file. When an | |
# application is linked to this library, the | |
# linker will extract the appropriate platform | |
# version and use that. | |
# The library file is given the same name as the | |
# framework with no .a extension. | |
[ -f "$FRAMEWORK_INPUT_ARM_FILES" ] || \ | |
echo "error: arm library $FRAMEWORK_INPUT_ARM_FILES not present."; | |
[ -f "$FRAMEWORK_INPUT_I386_FILES" ] || \ | |
echo "error: i386 library $FRAMEWORK_INPUT_I386_FILES not present."; | |
if [ ! -f "$FRAMEWORK_INPUT_I386_FILES" ] || \ | |
[ ! -f "$FRAMEWORK_INPUT_ARM_FILES" ] | |
then | |
exit; | |
fi | |
echo "$CMD Creating library..." | |
lipo \ | |
-create \ | |
"$FRAMEWORK_INPUT_ARM_FILES" \ | |
-arch i386 "$FRAMEWORK_INPUT_I386_FILES" \ | |
-o "$FRAMEWORK_DIR/Versions/Current/$FRAMEWORK_NAME" | |
# Now copy the final assets over: your library | |
# header files and the plist file | |
echo "$CMD Copying assets into current version..." | |
cp ../../Lumberjack/*.h $FRAMEWORK_DIR/Headers/ | |
cp Framework.plist $FRAMEWORK_DIR/Resources/Info.plist | |
# all done! | |
echo "$CMD success." | |
if [ "$CONFIGURATION" == "$FRAMEWORK_TARBALL_CONFIGURATION" ] | |
then | |
# Package up | |
echo "$CMD packaging $CONFIGURATION tarball..." | |
mkdir -p $FRAMEWORK_TARBALL_PATH | |
cd $FRAMEWORK_BUILD_PATH | |
tar -czf $FRAMEWORK_TARBALL $FRAMEWORK_NAME.framework | |
cd - > /dev/null | |
mv $FRAMEWORK_BUILD_PATH/$FRAMEWORK_TARBALL \ | |
$FRAMEWORK_TARBALL_PATH/$FRAMEWORK_TARBALL | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added Release tarballing =)