Skip to content

Add install.sh: automated macOS installer for Copilot for Xcode#2

Open
Copilot wants to merge 3 commits intomainfrom
copilot/install-package
Open

Add install.sh: automated macOS installer for Copilot for Xcode#2
Copilot wants to merge 3 commits intomainfrom
copilot/install-package

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 26, 2026

No streamlined CLI install path exists — users must know the Homebrew cask name or navigate GitHub releases manually.

install.sh (new)

  • Validates macOS ≥ 12 and Xcode via xcode-select
  • Installs via brew install --cask copilot-for-xcode when Homebrew is available; falls back to GitHub Releases API → ZIP download → extract → copy to /Applications
  • Launches the app once to register its background launch agent
  • Prints version-aware post-install steps (macOS 15 / 14 / older) for enabling the Source Editor Extension, granting Accessibility permission, and configuring an AI provider
bash <(curl -fsSL https://raw.githubusercontent.com/intitni/CopilotForXcode/main/install.sh)

README.md

  • Install section now leads with the one-liner above; existing Homebrew and manual download instructions retained below it

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 26, 2026 18:01
Co-authored-by: luisespersonal-byte <249453885+luisespersonal-byte@users.noreply.github.com>
Co-authored-by: luisespersonal-byte <249453885+luisespersonal-byte@users.noreply.github.com>
Copilot AI changed the title [WIP] Add installation of new package Add install.sh: automated macOS installer for Copilot for Xcode Feb 26, 2026
@luisespersonal-byte luisespersonal-byte marked this pull request as ready for review February 26, 2026 18:30
Copilot AI review requested due to automatic review settings February 26, 2026 18:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a streamlined CLI installation path for Copilot for Xcode by introducing a macOS installer script and updating the README to promote it alongside existing Homebrew/manual options.

Changes:

  • Added install.sh to automate prerequisite checks, installation (Homebrew cask or GitHub Releases fallback), first launch, and post-install guidance.
  • Updated README.md install section to lead with a curl-based one-liner and include a “run from clone” variant.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
install.sh New automated installer script with Homebrew-first install and GitHub Releases fallback plus post-install instructions.
README.md Promotes the one-line installer and retains existing Homebrew/manual install paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +52 to +59
# Xcode installed (look for the app bundle or xcode-select path)
if ! xcode-select -p &>/dev/null || [[ ! -d "$(xcode-select -p)" ]]; then
error "Xcode does not appear to be installed."
error "Install Xcode from the Mac App Store, then re-run this script."
exit 1
fi
success "Xcode found at $(xcode-select -p)"

Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Xcode check currently accepts Command Line Tools-only setups because xcode-select -p can point to /Library/Developer/CommandLineTools. Since the product is an Xcode Source Editor extension, it likely needs the full Xcode.app. Consider verifying that xcode-select -p resolves under an actual Xcode.app/Contents/Developer (or that /Applications/Xcode.app exists) and emitting a clearer error if only CLT is installed.

Suggested change
# Xcode installed (look for the app bundle or xcode-select path)
if ! xcode-select -p &>/dev/null || [[ ! -d "$(xcode-select -p)" ]]; then
error "Xcode does not appear to be installed."
error "Install Xcode from the Mac App Store, then re-run this script."
exit 1
fi
success "Xcode found at $(xcode-select -p)"
# Xcode installed (require full Xcode, not just Command Line Tools)
xcode_path="$(xcode-select -p 2>/dev/null || true)"
if [[ -z "$xcode_path" || ! -d "$xcode_path" ]]; then
error "Xcode does not appear to be installed."
error "Install Xcode from the Mac App Store, then re-run this script."
exit 1
fi
# Detect Command Line Tools-only setup and prefer the full Xcode.app if present
if [[ "$xcode_path" == /Library/Developer/CommandLineTools* ]]; then
if [[ -d "/Applications/Xcode.app/Contents/Developer" ]]; then
xcode_path="/Applications/Xcode.app/Contents/Developer"
else
error "Only Xcode Command Line Tools were detected at: $xcode_path"
error "${APP_NAME} requires the full Xcode.app (including Source Editor Extensions)."
error "Install Xcode from the Mac App Store, then re-run this script."
exit 1
fi
fi
success "Xcode found at $xcode_path"

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +79
asset_url=$(
curl -fsSL "$GITHUB_RELEASES" \
| grep '"browser_download_url"' \
| grep '\.zip"' \
| head -1 \
| sed 's/.*"browser_download_url": "\(.*\)"/\1/'
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GitHub Releases lookup runs inside a command substitution with set -e + pipefail, so if the API call fails (rate limit/network, 403/404), the script will exit immediately without printing the friendly fallback errors below. Consider capturing the curl output/exit code explicitly (or retrying / surfacing the HTTP error) so users get a clear message and manual-download link instead of a silent abort.

Suggested change
asset_url=$(
curl -fsSL "$GITHUB_RELEASES" \
| grep '"browser_download_url"' \
| grep '\.zip"' \
| head -1 \
| sed 's/.*"browser_download_url": "\(.*\)"/\1/'
# Fetch release JSON from GitHub, handling HTTP/network errors explicitly
if ! release_json=$(curl -fsSL "$GITHUB_RELEASES"); then
error "Failed to contact GitHub Releases API."
error "Please download ${APP_NAME} manually from:"
error " https://github.com/intitni/CopilotForXcode/releases"
exit 1
fi
# Extract the first .zip asset URL from the release JSON
asset_url=$(
printf '%s\n' "$release_json" \
| grep '"browser_download_url"' \
| grep '\.zip"' \
| head -1 \
| sed 's/.*"browser_download_url": "\(.*\)"/\1/' \
|| true

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +103
extracted_app=$(find "$tmp_dir" -maxdepth 3 -name "*.app" | head -1)
if [[ -z "$extracted_app" ]]; then
error "Could not find the .app bundle inside the downloaded archive."
rm -rf "$tmp_dir"
exit 1
fi
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find ... -name "*.app" | head -1 can select the wrong bundle if the extracted archive contains multiple .apps (e.g., helper apps inside the main app bundle). Prefer selecting the expected bundle name (e.g., ${APP_BUNDLE}) and/or limiting the search depth so you always install the host app.

Copilot uses AI. Check for mistakes.
Comment on lines +105 to +109
info "Moving ${APP_BUNDLE} to /Applications …"
# Remove a stale copy if present (handles re-install after failed attempt)
[[ -d "$APP_PATH" ]] && rm -rf "$APP_PATH"
cp -R "$extracted_app" "$APP_PATH"
rm -rf "$tmp_dir"
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying/removing under /Applications often requires admin privileges. As written, rm -rf / cp -R will fail with a permission error for many users (and set -e will exit without guidance). Consider detecting writability of /Applications (or $APP_PATH) and using sudo when needed, with a clear prompt/message.

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +96
tmp_dir=$(mktemp -d)
zip_path="${tmp_dir}/CopilotForXcode.zip"

info "Downloading ${APP_NAME} …"
curl -fL --progress-bar "$asset_url" -o "$zip_path"

info "Extracting …"
unzip -q "$zip_path" -d "$tmp_dir"
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temp directory is only cleaned up on the success path and a couple of specific error branches. If curl, unzip, or the copy step fails, tmp_dir will be left behind. Consider using a trap to ensure cleanup on any exit (success or failure).

Copilot uses AI. Check for mistakes.
Comment on lines +127 to +128
os_minor=$(echo "$os_version" | cut -d. -f2)

Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os_minor is computed but never used. Please remove it (or use it) to avoid dead code / confusion.

Suggested change
os_minor=$(echo "$os_version" | cut -d. -f2)

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +96
**One-line installer** — runs the bundled `install.sh` script which handles the download, moves the app to `/Applications`, and prints the remaining manual steps:

```bash
bash <(curl -fsSL https://raw.githubusercontent.com/intitni/CopilotForXcode/main/install.sh)
```
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one-liner installs by executing install.sh fetched from the main branch via raw.githubusercontent.com, not a locally "bundled" script. Consider rewording to avoid implying it runs a script shipped with a downloaded release/clone, and (optionally) note that it always pulls the latest script from main rather than a pinned release for reproducibility.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants