Last active
July 9, 2024 06:29
-
-
Save pwc3/09b5dc326837e210b73daa63cd13503e to your computer and use it in GitHub Desktop.
Revisions
-
pwc3 revised this gist
Dec 18, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ #!/usr/bin/env bash # Converts a legacy framework into an xcframework. # Usage: convert-framework.sh input_framework output_xcframework set -euo pipefail -
pwc3 created this gist
Dec 18, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ #!/usr/bin/env bash # Converts a legacy framework into an xcframework. set -euo pipefail E_BADARGS=85 if [ $# -ne 2 ]; then echo "Usage: $(basename $0) framework xcframework" exit $E_BADARGS fi # The source framework directory framework_dir="$1" # The destination xcframework location xcframework="$2" # Extract the basename of the framework, stripping off the path and leaving only Foo.framework framework_basename="$(basename -- "$framework_dir")" # Extract the name of the framework, leaving only Foo framework_name="${framework_basename%.*}" # Make a temporary working directory tmpdir="$(mktemp -d ${TMPDIR:-/tmp}/convert-framework.XXXXXX)" echo "Working directory: $tmpdir" # This is based on an approach recommended here: # https://github.com/twilio/twilio-voice-ios/issues/64#issuecomment-747186499 mkdir "$tmpdir/arm64" mkdir "$tmpdir/x86_64" cp -R "$framework_dir" "$tmpdir/arm64/$framework_basename" cp -R "$framework_dir" "$tmpdir/x86_64/$framework_basename" echo "Extracting arm64 from framework" pushd "$tmpdir/arm64" > /dev/null lipo \ -extract arm64 \ -output "$framework_basename/$framework_name" \ "$framework_basename/$framework_name" echo "Updating CFBundleSupportedPlatforms in arm64/$framework_basename/Info.plist" plutil \ -replace CFBundleSupportedPlatforms \ -xml "<array><string>iPhoneOS</string></array>" \ "$framework_basename/Info.plist" popd > /dev/null echo "Extracting x86_64 from framework" pushd "$tmpdir/x86_64" > /dev/null lipo \ -extract x86_64 \ -output "$framework_basename/$framework_name" \ "$framework_basename/$framework_name" echo "Updating CFBundleSupportedPlatforms in x86_64/$framework_basename/Info.plist" plutil \ -replace CFBundleSupportedPlatforms \ -xml "<array><string>iPhoneSimulator</string></array>" \ "$framework_basename/Info.plist" popd > /dev/null echo "Building xcframework at $xcframework" xcodebuild \ -create-xcframework \ -framework "$tmpdir/arm64/$framework_basename" \ -framework "$tmpdir/x86_64/$framework_basename" \ -output "$xcframework" echo "Done"