Created
May 18, 2019 15:31
-
-
Save steventroughtonsmith/d94e443e97efd18fc8d61006ff40ca80 to your computer and use it in GitHub Desktop.
Converts an ARM64 iOS app with Bitcode into an X86_64 variant
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 | |
TARGET="$( cd "$(dirname "$1")" ; pwd -P )/$1" | |
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk" | |
TARGET_ARCH=x86_64 | |
export IPHONEOS_DEPLOYMENT_TARGET=12.2 | |
rm -r /tmp/bitcode2intel | |
mkdir -p /tmp/bitcode2intel | |
pushd /tmp/bitcode2intel | |
ebcutil -a arm64 -e "$TARGET" | |
echo "Starting conversion of $TARGET" | |
for f in /tmp/bitcode2intel/*; | |
do clang -miphoneos-version-min=$IPHONEOS_DEPLOYMENT_TARGET -arch $TARGET_ARCH -fembed-bitcode -c -Xclang -disable-llvm-passes -emit-llvm -x ir -isysroot $SYSROOT $f -o $f.o; | |
done | |
clang -miphoneos-version-min=$IPHONEOS_DEPLOYMENT_TARGET -arch $TARGET_ARCH -fembed-bitcode -isysroot $SYSROOT *.o -o "$TARGET".intel | |
lipo "$TARGET" -remove $TARGET_ARCH -o "$TARGET" | |
lipo "$TARGET" -create -arch_blank $TARGET_ARCH -o "$TARGET" | |
lipo "$TARGET" -replace $TARGET_ARCH "$TARGET".intel -o "$TARGET" | |
popd | |
rm -r /tmp/bitcode2intel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment