Skip to content

Instantly share code, notes, and snippets.

@DianQK

DianQK/xcode_slim.sh

Created Oct 10, 2020
Embed
What would you like to do?
#!/bin/bash
XCODE_DEVELOPER_PATH="/Applications/Xcode.app/Contents/Developer"
thin()
{
file=$1
archs=`file $file`
if [[ $archs == *"x86_64"* ]]; then
if [[ $archs == *"arm64"* ]]; then
echo "thin $file"
lipo $file -thin x86_64 -output $file
fi
fi
}
thin_folder()
{
folder=$1
echo "thin_folder $folder"
for entry in $folder/*
do
thin $entry
done
}
thin_usr()
{
thin_folder $XCODE_DEVELOPER_PATH/usr/bin
thin_folder $XCODE_DEVELOPER_PATH/usr/lib
}
thin_toochains()
{
XcodeDefault_xctoolchain=$XCODE_DEVELOPER_PATH/Toolchains/XcodeDefault.xctoolchain
thin_folder $XcodeDefault_xctoolchain/usr/bin
thin_folder $XcodeDefault_xctoolchain/usr/metal/ios/bin
thin_folder $XcodeDefault_xctoolchain/usr/metal/macos/bin
thin_folder $XcodeDefault_xctoolchain/usr/lib
thin_folder $XcodeDefault_xctoolchain/usr/lib/sourcekitd.framework/Versions/Current/
}
rm_platform()
{
rm -rf $XCODE_DEVELOPER_PATH/Platforms/AppleTVSimulator.platform
rm -rf $XCODE_DEVELOPER_PATH/Platforms/AppleTVOS.platform
rm -rf $XCODE_DEVELOPER_PATH/Platforms/WatchSimulator.platform
rm -rf $XCODE_DEVELOPER_PATH/Platforms/WatchOS.platform
}
thin_ios_platform()
{
RuntimeRoot=$XCODE_DEVELOPER_PATH/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
for entry in $RuntimeRoot/System/Library/PrivateFrameworks/*.framework
do
thin_folder $entry
done
for entry in $RuntimeRoot/System/Library/Frameworks/*.framework
do
thin_folder $entry
done
}
thin_usr
thin_toochains
rm_platform
thin_ios_platform
@jesseluo

This comment has been minimized.

Copy link

@jesseluo jesseluo commented Oct 10, 2020

青总🐂🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment