Last active
August 5, 2021 09:18
-
-
Save Bengejd/df5dbbd807b5822761194d601149b86d to your computer and use it in GitHub Desktop.
XCode - Build Phase Script - Remove unsupported archetypes ( simulator x86_64 & i386) from frameworks on build.
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
# This removes the unsupported archetypes from frameworks on the build phase. | |
echo "Target architectures: $ARCHS" | |
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}" | |
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK | |
do | |
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable) | |
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME" | |
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH" | |
echo $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH") | |
FRAMEWORK_TMP_PATH="$FRAMEWORK_EXECUTABLE_PATH-tmp" | |
# remove simulator's archs if location is not simulator's directory | |
case "${TARGET_BUILD_DIR}" in | |
*"iphonesimulator") | |
echo "No need to remove archs" | |
;; | |
*) | |
if $(lipo "$FRAMEWORK_EXECUTABLE_PATH" -verify_arch "i386") ; then | |
lipo -output "$FRAMEWORK_TMP_PATH" -remove "i386" "$FRAMEWORK_EXECUTABLE_PATH" | |
echo "i386 architecture removed" | |
rm "$FRAMEWORK_EXECUTABLE_PATH" | |
mv "$FRAMEWORK_TMP_PATH" "$FRAMEWORK_EXECUTABLE_PATH" | |
fi | |
if $(lipo "$FRAMEWORK_EXECUTABLE_PATH" -verify_arch "x86_64") ; then | |
lipo -output "$FRAMEWORK_TMP_PATH" -remove "x86_64" "$FRAMEWORK_EXECUTABLE_PATH" | |
echo "x86_64 architecture removed" | |
rm "$FRAMEWORK_EXECUTABLE_PATH" | |
mv "$FRAMEWORK_TMP_PATH" "$FRAMEWORK_EXECUTABLE_PATH" | |
fi | |
;; | |
esac | |
echo "Completed for executable $FRAMEWORK_EXECUTABLE_PATH" | |
echo $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH") | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment