Created
November 13, 2018 03:10
-
-
Save natbro/c20681013f67e2f62615d423fe09556b to your computer and use it in GitHub Desktop.
script to link older macOS SDKs into newer Xcode so you can target older platforms properly
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 | |
# --------------------------------------------------------------------------------------------------------- | |
# place as many old macOS SDKs into the directory with this script e.g. if you have | |
# | |
# my-macpro:SDKs natb$ ls -ahl | |
# total 4254792 | |
# drwxr-xr-x 17 natb admin 578B Nov 21 2017 . | |
# drwxrwxr-x 24 root admin 884B Aug 29 06:46 .. | |
# drwxr-xr-x 5 natb admin 170B Oct 17 2017 MacOSX10.10.sdk | |
# drwxr-xr-x 5 natb admin 170B Oct 17 2017 MacOSX10.11.sdk | |
# drwxr-xr-x 5 natb admin 170B Oct 17 2017 MacOSX10.12.sdk | |
# drwxr-xr-x 5 natb admin 170B Oct 17 2017 MacOSX10.13.sdk | |
# drwxr-xr-x 7 natb admin 238B Oct 17 2017 MacOSX10.6.sdk | |
# drwxr-xr-x 7 natb admin 238B Oct 17 2017 MacOSX10.7.sdk | |
# drwxr-xr-x 5 natb admin 170B Oct 17 2017 MacOSX10.8.sdk | |
# drwxr-xr-x 5 natb admin 170B Oct 17 2017 MacOSX10.9.sdk | |
# | |
# then run it to allow your current version of Xcode is to have access to SDKs back to 10.6 | |
# tested with Xcode 8.x - 9.4.x. Works with Xcode 10, but Xcode 10 will not support 32-bit targets | |
# and complains indefinitely for 9.4.x and higher. I suggest 9.2.x as your stopping point if | |
# you plan to build universal/fat binaries that can run pre-10.14 | |
# this same tactic works for iOS and tvOS SDKs. | |
# --------------------------------------------------------------------------------------------------------- | |
SDK_DIR="$(cd $(dirname $0) && echo $PWD)" | |
OSX_PLAT=`xcrun --sdk macosx --show-sdk-platform-path` | |
OSX_SDK=$OSX_PLAT/Developer/SDKs | |
pushd "$OSX_SDK" | |
# this links | |
sudo ln -sfn "$SDK_DIR"/* . | |
# this is a magic tweak for an ommission in the 10.9 SDK which can trip you up | |
if [ -e "$SDK_DIR/MacOSX10.10.sdk/usr/lib/crt1.10.6.o" -a ! -e "$SDK_DIR/MacOSX10.9.sdk/usr/lib/crt1.10.6.o" ] | |
then | |
cp "$SDK_DIR/MacOSX10.10.sdk/usr/lib/crt1.10.6.o" "$SDK_DIR/MacOSX10.9.sdk/usr/lib/" | |
fi | |
popd | |
# this is the magic tweak to Info.plist to enable older SDKs that you have symlink'd in | |
sudo plutil -replace MinimumSDKVersion -string 10.6 "$OSX_PLAT"/Info.plist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment