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
- Create a new project from the ESP32-C6 template
- Cmd+B (triggers
setup_scheme.sh via build.sh)
- Try Cmd+R → fails (alert sound)
- Close the project (not Xcode)
- Reopen the project from Recent or Finder
- 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
Problem
After
setup_scheme.shgenerates a.xcschemefile on first build,Xcode does not pick up the new scheme until the project is closed and reopened.
Symptoms:
Product → Runmenu item is grayed outCmd+Rproduces an alert sound (key binding inactive)Cmd+B) works fineAfter closing the project window and reopening it:
Runbecomes active~/.espswift/scripts/monitoras expectedReproduction
setup_scheme.shviabuild.sh)Why This Happens (Hypothesis)
Xcode caches scheme metadata in memory when a project is opened.
Externally created
.xcschemefiles are read once on open, so subsequentfile 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:
touchon project filesxcodebuild -listinvocationCurrent Workaround
Manual: close and reopen the project after first build.
Related