Xcode 15.0: "expand macro" stays greyed out

410 views Asked by At

“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.

2

There are 2 answers

0
AncilTech On BEST ANSWER

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.

1
lorem ipsum On

@Observable is only available in

iOS 17.0+ iPadOS 17.0+ macOS 14.0+ Mac Catalyst 17.0+ tvOS 17.0+ watchOS 10.0+ visionOS 1.0+ Beta

You cannot use it for macOS 13.5. I don't think any of the macros work below macOS 14.