Last active
December 17, 2025 03:20
-
-
Save tikipatel/462986dc57224c4bbec2f9f7b61dd45e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| # Install brew | |
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| install_brew_package() { | |
| local package_name=$1 | |
| local command_name=${2:-$package_name} | |
| echo "Checking if ${package_name} is installed..." | |
| if [[ $(command -v "${command_name}") == "" ]]; then | |
| echo "${package_name} not found. Installing ${package_name} using Homebrew..." | |
| brew install "${package_name}" | |
| # Verify installation | |
| if [[ $(command -v "${command_name}") == "" ]]; then | |
| echo "Error: Failed to install ${package_name}. Please install manually." | |
| exit 1 | |
| else | |
| echo "${package_name} installed successfully!" | |
| fi | |
| else | |
| echo "${package_name} is already installed." | |
| fi | |
| } | |
| # Make sure brew is in PATH after installation | |
| echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>~/.bash_profile | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| install_brew_package "xcodegen" | |
| install_brew_package "yq" | |
| install_brew_package "periphery" | |
| pip3 install pyyaml | |
| # So that any xcode-select or xcode-build commands run with sudo don't require password | |
| echo "%admin ALL=NOPASSWD: /usr/bin/xcode-select,/usr/bin/xcodebuild -runFirstLaunch" | sudo tee /etc/sudoers.d/xcode | |
| echo "Installing xcpretty via gem..." | |
| sudo gem install xcpretty | |
| echo "Installing Metal toolchain if required" | |
| # Check if the Metal toolchain is installed | |
| if xcodebuild -showComponent metalToolchain >/dev/null 2>&1; then | |
| echo "✅ Metal toolchain is already installed" | |
| else | |
| echo "❌ Metal toolchain is not installed. Downloading and installing..." | |
| # Define a temporary directory for the download | |
| DOWNLOAD_DIR="/tmp/metalToolchainDownload/" | |
| mkdir -p "$DOWNLOAD_DIR" | |
| # Download the component | |
| xcodebuild -downloadComponent metalToolchain -exportPath "$DOWNLOAD_DIR" | |
| # Find the name of the exported bundle and import it | |
| BUNDLE_PATH=$(find "$DOWNLOAD_DIR" -name "*.exportedBundle") | |
| if [ -n "$BUNDLE_PATH" ]; then | |
| xcodebuild -importComponent metalToolchain -importPath "$BUNDLE_PATH" | |
| echo "🧰 Metal toolchain installed successfully" | |
| else | |
| echo "❌ Failed to find exported bundle" | |
| exit 1 | |
| fi | |
| # Clean up the temporary download directory | |
| rm -rf "$DOWNLOAD_DIR" | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment