-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
strip-xcode.sh
executable file
·69 lines (60 loc) · 2.2 KB
/
strip-xcode.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
set -e
if [ -n "$1" ]; then
cd "$1"
fi
cd Contents
mkdir PlugIns-new
mv PlugIns/Xcode3Core.ideplugin PlugIns/IDEiOSSupportCore.ideplugin PlugIns-new
rm -rf PlugIns
mv PlugIns-new PlugIns
rm -rf Applications _CodeSignature Frameworks Library MacOS OtherFrameworks Resources SharedFrameworks XPCServices _MASReceipt Info.plist PkgInfo version.plist
cd Developer
rm -rf Applications Documentation Library Makefiles Tools usr
mkdir -p usr/bin
cd Toolchains/XcodeDefault.xctoolchain/usr
rm -rf bin
mkdir bin
# Fill in usr/bin later with wrappers/scripts
rm -rf lib/*swift* lib/*.dylib lib/*.framework
rm -rf metal
cd ../../..
mkdir Toolchains-new
mv Toolchains/XcodeDefault.xctoolchain Toolchains-new
rm -rf Toolchains
mv Toolchains-new Toolchains
cd Platforms
cd MacOSX.platform
rm -rf usr _CodeSignature
cd Developer/SDKs/MacOSX10.*sdk
rm -rf usr/share
cd ../../../..
for sdk in iPhone Watch AppleTV; do
OS=${sdk}OS
SIM=${sdk}Simulator
cd $OS.platform
rm -rf DeviceSupport usr _CodeSignature Developer/Library/CoreSimulator Library/Developer/CoreSimulator
cd ..
cd $SIM.platform
rm -rf Developer/Library/CoreSimulator Developer/Library/Frameworks Developer/Library/PrivateFrameworks _CodeSignature
cd Developer/SDKs/$SIM.sdk
rm -rf usr/share usr/libexec Library Developer Applications
# On Xcode 9.x and newer, usr/lib contains tbd files for the libraries,
# and linking to them for simulator builds succeeds. On Xcode 8.x and
# older, the usr/lib dir contains large dylib files, and linking
# against them doesn't succeed anyway (it's missing
# /usr/lib/system/libsystem_kernel.dylib). Thus remove the large files
# from older SDKs, while keeping enough for linking to succeed on
# newer SDks.
rm -rf usr/lib/system usr/lib/*.dylib
if [ ! -e System/Library/Frameworks/Foundation.framework/Foundation.tbd ]; then
# Xcode 7.x and 8.x has got full frameworks for the simulator here,
# replace them with thin frameworks with TBD files for the target.
# Xcode 9 has got TBD files for the simulator as well.
# On Xcode 9/iOS 11 SDK, building for the simulatorh with header
# files taken from the target breaks.
rm -rf System
cp -a ../../../../$OS.platform/Developer/SDKs/$OS.sdk/System .
fi
cd ../../../..
done