Files
qt5/coin/provisioning/common/macos/install_xcode.sh
Tor Arne Vestbø 50086ff8f3 Explicitly install iOS and visionOS platforms for Xcode 26
The app no longer ships with any platforms (SDKs) built in
except for the macOS platform.

Pick-to: 6.12
Change-Id: I83200553f52b9edf80212a12bb9abd6a26f27407
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2026-06-08 22:30:41 +00:00

72 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright (C) 2021 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
set -ex
# shellcheck source=./../unix/DownloadURL.sh
source "${BASH_SOURCE%/*}/../unix/DownloadURL.sh"
# This script installs Xcode
# Prerequisites: Have Xcode prefetched to local cache as xz compressed.
# This can be achieved by fetching Xcode_8.xip from Apple Store.
# Uncompress it with 'xar -xf Xcode_8.xip'
# Then get https://gist.githubusercontent.com/pudquick/ff412bcb29c9c1fa4b8d/raw/24b25538ea8df8d0634a2a6189aa581ccc6a5b4b/parse_pbzx2.py
# with which you can run 'python parse_pbzx2.py Content'.
# This will give you a file called "Content.part00.cpio.xz" that
# can be renamed to Xcode_8.xz for this script.
function InstallXCode() {
sourceFile=$1
version=$2
if ! [[ $version =~ ^[0-9] ]]; then
echo "Error: version input must start with a digit"
exit 1
fi
echo "Uncompressing and installing '$sourceFile'"
if [[ $sourceFile =~ tar ]]; then
cd /Applications/ && sudo tar -zxf "$sourceFile"
elif [[ $sourceFile =~ "xip" ]]; then
if [[ $sourceFile =~ "http" ]]; then
Download "$sourceFile" "/Applications/Xcode_$version.xip"
cd /Applications/ && xip -x "Xcode_$version.xip"
else
cd /Applications/ && xip -x "$sourceFile"
fi
else
xzcat < "$sourceFile" | (cd /Applications/ && sudo cpio -dmi)
fi
echo "Versioning application bundle"
majorVersion="${version%%[^0-9]*}"
versionedAppBundle="/Applications/Xcode${majorVersion}.app"
sudo mv /Applications/Xcode*.app "${versionedAppBundle}"
echo "Selecting Xcode"
sudo xcode-select --switch "${versionedAppBundle}"
echo "Accept license"
sudo xcodebuild -license accept
echo "Install packages"
sudo xcodebuild -runFirstLaunch
# Xcode 26 ships a more minimal base install
if ((majorVersion >= 26)); then
xcodebuild -downloadComponent MetalToolchain
xcodebuild -downloadPlatform iOS
if [[ $(uname -m) == "arm64" ]]; then
xcodebuild -downloadPlatform visionOS
fi
fi
echo "Enabling developer mode, so that using lldb does not require interactive password entry"
sudo /usr/sbin/DevToolsSecurity -enable
echo "Xcode = $version" >> ~/versions.txt
}