Skip to content

Xcode does not reload .xcscheme until project is closed and reopened #3

@letstakeabreak

Description

@letstakeabreak

Problem

After setup_scheme.sh generates a .xcscheme file on first build,
Xcode does not pick up the new scheme until the project is closed and reopened.

Symptoms:

  • Product → Run menu item is grayed out
  • Cmd+R produces an alert sound (key binding inactive)
  • Build (Cmd+B) works fine

After closing the project window and reopening it:

  • Run becomes active
  • The scheme launches ~/.espswift/scripts/monitor as expected

Reproduction

  1. Create a new project from the ESP32-C6 template
  2. Cmd+B (triggers setup_scheme.sh via build.sh)
  3. Try Cmd+R → fails (alert sound)
  4. Close the project (not Xcode)
  5. Reopen the project from Recent or Finder
  6. Cmd+R → works

Why This Happens (Hypothesis)

Xcode caches scheme metadata in memory when a project is opened.
Externally created .xcscheme files are read once on open, so subsequent
file system changes don't take effect during the current session.

Possible Solutions

Option 1: User-facing message

Print a clear message after first build:

✅ Scheme created. Please close and reopen this project to enable Run.

Simple but adds friction.

Option 2: AppleScript automation

Use AppleScript to close and reopen the project automatically.
Risk: may interrupt unsaved work.

Option 3: Find a way to trigger Xcode's scheme reload

Possible approaches to investigate:

  • touch on project files
  • xcodebuild -list invocation
  • AppleScript "reveal" or similar non-destructive trigger

Current Workaround

Manual: close and reopen the project after first build.

Related

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions