Xcode First-Launch Component Installation After a Failed Upgrade
0 reputation · 01 Feb 2020, 05:44 UTC
0 reputation · 01 Feb 2020, 05:44 UTC
After a failed Xcode upgrade, the application may stay at the previous version while the system still references a partially upgraded bundle, causing the developer directory reported by xcode-select to be missing. A clean reinstall of Xcode can restore the correct bundle, but it is unclear whether the first‑launch tasks that install optional components such as simulator runtimes and SwiftUI previews are automatically executed in this scenario or if they are skipped because the bundle appears already present.
The goal is to recover a fully functional Xcode installation without manually invoking recovery commands, while respecting the system’s permission boundaries and avoiding unintended side effects on other developer tools.
Does a clean reinstall of Xcode after a failed upgrade automatically trigger the first‑launch component installation? If not, what configuration or permission change is required to ensure those tasks run? Is invoking xcodebuild -runFirstLaunch the only supported method to recover the missing components?
31775 reputation · 01 Feb 2020, 12:06 UTC
A clean reinstall of Xcode does not reliably re-trigger first-launch component installation after a failed upgrade. The reinstall restores the bundle, but first-launch tasks are gated by the active developer directory reported by xcode-select and by per-user first-launch state. If xcode-select still points to a missing or partial developer directory, or if a prior first-launch marker persists, Xcode will open as if it is already set up and will skip the welcome/license and optional component offers.
xcodebuild -runFirstLaunch is not the supported recovery method. It is an undocumented internal trigger and is version sensitive. Supported recovery is to correct the developer directory selection, launch Xcode.app once as the regular user, accept the license, and install components via Xcode Settings > Platforms.
xcode-select. If the path does not exist, build tools and first-launch tasks fail.xcodebuild as root to recover components. Root ownership can break future first-launch tasks.After a failed upgrade the system can retain a stale xcode-select path that points to a removed or partial Contents/Developer. A clean reinstall restores /Applications/Xcode.app but does not automatically reset the selection. Xcode therefore believes the developer directory is already known and skips first-launch setup. A persistent per-user first-launch marker can also make Xcode think setup is complete.
xcode-select -pThe path should exist and point to /Applications/Xcode.app/Contents/Developer.
sudo xcode-select --resetOr explicitly switch if Xcode is not in the default location:
sudo xcode-select --switch /Applications/Xcode.appxcodebuild -versionxcode-select -p returns an existing path.xcodebuild -version matches the installed Xcode bundle.~/Library/Logs/Xcode contains first-launch and component installation logs after launch.Note: component installation behavior is version sensitive between Xcode and macOS. If the above steps do not present the first-launch UI, provide the macOS version and the Xcode version you reinstalled. That detail changes whether Developer Mode or a specific TCC reset is required.
Use comments to ask for clarification. Post a solution as an answer.
3,880 reputation · 01 Feb 2020, 12:39 UTC
One detail worth adding to the existing answer: the first-launch decision is partly driven by per-user state, not just the bundle or xcode-select. Xcode records that first-launch tasks completed for a given version in the user's preferences, so after a failed upgrade you can end up with a marker claiming a newer version was initialized while the components were never actually installed. That is why simply relaunching Xcode.app sometimes shows no prompt at all.
Before reinstalling again, I would verify rather than assume:
xcode-select -p resolves to the real /Applications/Xcode.app/Contents/Developerxcodebuild -checkFirstLaunchStatus (available in recent Xcode versions) reports whether first-launch is pendingxcrun simctl list runtimes shows whether simulator content actually survivedIf the status check reports pending, xcodebuild -runFirstLaunch from the regular user is the deterministic trigger. Exact subcommand availability is version-sensitive, so confirm against your installed Xcode before scripting it.