Skip to content

Instantly share code, notes, and snippets.

@LeonardoCardoso
Created July 20, 2018 11:53
Show Gist options
  • Save LeonardoCardoso/f76a0a23c072e96da51fba8ce1fbd589 to your computer and use it in GitHub Desktop.
Save LeonardoCardoso/f76a0a23c072e96da51fba8ce1fbd589 to your computer and use it in GitHub Desktop.
Fat Framework
#!/usr/bin/env bash
PRODUCTS_PATH=$1
PROJECT_NAME=$2
VERSION=$3
if (( $# != 3 )); then
echo "Wrong usage. Please pass the correct arguments.
>> ./bind-frameworks PRODUCTS_PATH PROJECT_NAME VERSION"
else
# Remove all frameworks in the current folder
rm -Rf ./*.framework
# Copy frameworks
cp -R $PRODUCTS_PATH/Debug-iphoneos/$PROJECT_NAME.framework ./$PROJECT_NAME.framework
cp -R $PRODUCTS_PATH/Debug-iphonesimulator/$PROJECT_NAME.framework ./$PROJECT_NAME-sim.framework
# Bind frameworks
lipo -create ./$PROJECT_NAME-sim.framework/$PROJECT_NAME ./$PROJECT_NAME.framework/$PROJECT_NAME -output ./$PROJECT_NAME
# Move new framework binary into the final framework folder
mv ./$PROJECT_NAME ./$PROJECT_NAME.framework/
# Copy the architecture binaries
cp -R ./$PROJECT_NAME-sim.framework/Modules/$PROJECT_NAME.swiftmodule/* ./$PROJECT_NAME.framework/Modules/$PROJECT_NAME.swiftmodule/
# Delete simulateor framework
rm -Rf ./$PROJECT_NAME-sim.framework
# Add iPhoneSimulator as platform to binary Info.plist
plutil -insert CFBundleSupportedPlatforms.0 -string iPhoneSimulator ./$PROJECT_NAME.framework/Info.plist
# Zip project with the version
zip -r $VERSION.zip $PROJECT_NAME.framework/ -x "*.DS_Store"
# Delete framework
rm -Rf $PROJECT_NAME.framework
# Done
echo "Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment