Created
January 19, 2021 12:02
-
-
Save KaQuMiQ/5c02a27c736188e75d750c630cb9eb90 to your computer and use it in GitHub Desktop.
Convert fat binary framework into XCFramework
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/bash | |
mkdir ./arm64 | |
mkdir ./x86_64 | |
find "./" -name '*.framework' -type d | while read -r FRAMEWORK | |
do | |
echo "Preparing framework: $FRAMEWORK" | |
FRAMEWORK_EXECUTABLE_NAME=$(/usr/libexec/PlistBuddy -c "Print CFBundleExecutable" "$FRAMEWORK/Info.plist") | |
echo "Preparing arm64 framework" | |
cp -R "$FRAMEWORK" "./arm64/$FRAMEWORK_EXECUTABLE_NAME.framework" | |
rm "./arm64/$FRAMEWORK_EXECUTABLE_NAME.framework/$FRAMEWORK_EXECUTABLE_NAME" | |
$(/usr/libexec/PlistBuddy -c "Set CFBundleSupportedPlatforms iPhoneOS" "./arm64/$FRAMEWORK_EXECUTABLE_NAME.framework/Info.plist") | |
echo "Extracting arm64 from $FRAMEWORK_EXECUTABLE_NAME" | |
lipo -extract "arm64" "$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME" -o "./arm64/$FRAMEWORK_EXECUTABLE_NAME.framework/$FRAMEWORK_EXECUTABLE_NAME" | |
echo "Preparing x86_64 framework" | |
cp -R "$FRAMEWORK" "./x86_64/$FRAMEWORK_EXECUTABLE_NAME.framework" | |
rm "./x86_64/$FRAMEWORK_EXECUTABLE_NAME.framework" | |
$(/usr/libexec/PlistBuddy -c "Set CFBundleSupportedPlatforms iPhoneSimulator" "./x86_64/$FRAMEWORK_EXECUTABLE_NAME.framework/Info.plist") | |
echo "Extracting x86_64 from $FRAMEWORK_EXECUTABLE_NAME" | |
lipo -extract "x86_64" "$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME" -o "./x86_64/$FRAMEWORK_EXECUTABLE_NAME.framework/$FRAMEWORK_EXECUTABLE_NAME" | |
xcodebuild -create-xcframework -framework "./arm64/$FRAMEWORK_EXECUTABLE_NAME.framework" -framework "./x86_64/$FRAMEWORK_EXECUTABLE_NAME.framework" -output "$FRAMEWORK_EXECUTABLE_NAME.xcframework" || exit -1 | |
done | |
rm -r ./arm64 | |
rm -r ./x86_64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Blackjacx I have the same question, is there any way to convert the fat binary with resources to XCFramework including arm64-simulator slice?