iOS13 删除项目中所有模拟器架构
脚本如下:
!/bin/sh
strip_invalid_archs() {
binary="$1"
echo "current binary ${binary}"
Get architectures for current file
archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
stripped=""
echo "ARCHS is $archs"
for arch in $archs; do
if [ $arch == "i386" ];then
lipo -remove "i386" "$binary" -output "$binary"
fi
if [ $arch == "x86_64" ];then
lipo -remove "x86_64" "$binary" -output "$binary"
fi
done
lipo -info "$binary"
if [[ "$stripped" ]]; then
echo "Stripped $binary of architectures:$stripped"
fi
}
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
APP_PATH="$PWD"
echo $APP_PATH
This script loops through the frameworks embedded in the application and
removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
echo $FRAMEWORK
FRAMEWORK_EXECUTABLE_INFO_NAME="$FRAMEWORK/Info.plist"
if [ -f $FRAMEWORK_EXECUTABLE_INFO_NAME ]; then
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
echo "FRAMEWORK_EXECUTABLE_NAME is $FRAMEWORK_EXECUTABLE_NAME"
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
strip_invalid_archs "$FRAMEWORK_EXECUTABLE_PATH"
else
filename=${FRAMEWORK##/}
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/${filename%.}"
echo "Executable is: $FRAMEWORK_EXECUTABLE_PATH"
if [ -f $FRAMEWORK_EXECUTABLE_PATH ];then
strip_invalid_archs "$FRAMEWORK_EXECUTABLE_PATH"
else
echo " 文件不存在"
fi
fi
done