swiftxcodexcode15swift-macro

Xcode 15.0: "expand macro" stays greyed out


“Expand Macro” stays gray even though I’ve seen the @Observable macro expanding earlier.

enter image description here

However when I manually trigger build error it does expand the location of the error. In this case I target macOS 13.5 that doesn't support ObservationRegistrar.

enter image description here

I tried to restart Xcode, try different macros, different projects and types of projects.


Solution

  • I believe you are missing import Observation at the top of your file

    I ran into the same issue as it is not so straight forward that all the @Observable macros "work" in code, they just cant be expanded without importing first. Seems like the compiler does not require the import, just Xcode.