Created
March 11, 2019 15:16
-
-
Save manjuhere/4c48d2f285881fc16ccd91ca8a7ce639 to your computer and use it in GitHub Desktop.
Create a Universal Static Library/FAT framework for iOS. Combines arm (device) and x86(simulator) architectures.
This file contains hidden or 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 | |
CUR_DIR=$(eval "pwd") | |
if [[ $1 == '' ]]; then | |
echo "Provide scheme to generate the Frameworks" | |
echo "./framework-build.sh (scheme_name)" | |
exit 1 | |
fi | |
scheme=$1 | |
echo "Building for Device..." | |
xcodebuild -scheme $scheme SYMROOT="$CUR_DIR/Frameworks/Device" | |
DEV_LOC="$CUR_DIR/Frameworks/Device/Debug-iphoneos/$scheme.framework" | |
NEW_DEV_LOC="$CUR_DIR/Frameworks/Device/Debug-iphoneos/$scheme-dev.framework" | |
echo "Building for Simulator..." | |
xcodebuild -scheme $scheme -destination 'platform=iOS Simulator,name=iPhone XR,OS=12.1' SYMROOT="$CUR_DIR/Frameworks/Sim" | |
SIM_LOC="$CUR_DIR/Frameworks/Sim/Debug-iphonesimulator/$scheme.framework" | |
NEW_SIM_LOC="$CUR_DIR/Frameworks/Sim/Debug-iphonesimulator/$scheme-sim.framework" | |
echo "Renaming $DEV_LOC to $NEW_DEV_LOC" | |
mv $DEV_LOC $NEW_DEV_LOC | |
echo "Renaming $SIM_LOC to $NEW_SIM_LOC" | |
mv $SIM_LOC $NEW_SIM_LOC | |
echo "Moving $NEW_DEV_LOC to $CUR_DIR/Frameworks" | |
mv $NEW_DEV_LOC "$CUR_DIR/Frameworks" | |
echo "Moving $NEW_SIM_LOC to $CUR_DIR/Frameworks" | |
mv $NEW_SIM_LOC "$CUR_DIR/Frameworks" | |
echo "Removing Device and Sim Directories" | |
rm -r "$CUR_DIR/Frameworks/Device" | |
rm -r "$CUR_DIR/Frameworks/Sim" | |
echo "Backing up device framework" | |
cp -r "$CUR_DIR/Frameworks/$scheme-dev.framework" "$CUR_DIR/Frameworks/$scheme-device.framework" | |
echo "Creating FAT framework" | |
eval "lipo -create $CUR_DIR/Frameworks/$scheme-sim.framework/$scheme $CUR_DIR/Frameworks/$scheme-dev.framework/$scheme -output $CUR_DIR/Frameworks/$scheme" | |
echo "Copying swift module file" | |
mv "$CUR_DIR/Frameworks/$scheme" "$CUR_DIR/Frameworks/$scheme-dev.framework/" | |
echo "Appending iOS Simulator in Info.plist" | |
plutil -insert CFBundleSupportedPlatforms.1 -string iPhoneSimulator "$CUR_DIR/Frameworks/$scheme-dev.framework/Info.plist" | |
echo "copying simulator swiftmodule files to fat framework" | |
cp "$CUR_DIR/Frameworks/$scheme-sim.framework/Modules/$scheme.swiftmodule/x86_64.swiftdoc" "$CUR_DIR/Frameworks/$scheme-dev.framework/Modules/$scheme.swiftmodule/" | |
cp "$CUR_DIR/Frameworks/$scheme-sim.framework/Modules/$scheme.swiftmodule/x86_64.swiftmodule" "$CUR_DIR/Frameworks/$scheme-dev.framework/Modules/$scheme.swiftmodule/" | |
echo "renaming fat framework to actual framework name" | |
mv "$CUR_DIR/Frameworks/$scheme-dev.framework" "$CUR_DIR/Frameworks/$scheme.framework" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment