Skip to content

Instantly share code, notes, and snippets.

@hare1039
Last active August 3, 2021 23:19
Show Gist options
  • Save hare1039/0657790fa5bf76e5704aece62eaa65d9 to your computer and use it in GitHub Desktop.
Save hare1039/0657790fa5bf76e5704aece62eaa65d9 to your computer and use it in GitHub Desktop.
CURL_REQUEST_CMD=...;
XCODE_DL_LOCATION="/Volumes/Card512";
XCODE_TMP_EXTRACT_LOCATION="/Volumes/Card512/xcode";
XCODE_FINAL_EXTRACT_LOCATION="/Volumes/Card512"
# download xcode
cd "${XCODE_DL_LOCATION}" || \
{ echo "cd ${XCODE_DL_LOCATION} failed"; exit 1; }
while ! ${CURL_REQUEST_CMD} -o xcode.xip --continue -; do
echo "continue download";
done
# raw extract xpi (cannot use `xip --expand` because xip cannot filter extraction)
tar -zxvf xcode.xip -C "${XCODE_TMP_EXTRACT_LOCATION}";
# extract xcode.app
cd "${XCODE_FINAL_EXTRACT_LOCATION}" \
|| { echo "cd ${XCODE_FINAL_EXTRACT_LOCATION} failed"; exit 1; }
# if pbzx not installed, get it here
# https://github.com/NiklasRosenstein/pbzx.git
# brew install xz
# clang -I /usr/local/include pbzx.c -o pbzx -llzma -lxar
# skipping extracting CoreSimulator, which will take about > 70GB of space
pbzx -n "${XCODE_TMP_EXTRACT_LOCATION}/Content" | cpio -i -v -f '*CoreSimulator*'
# Setting the new xcode
# sudo xcode-select --switch ${XCODE_FINAL_EXTRACT_LOCATION}/Xcode.app
# sudo xcode-select --install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment