Description
Building any project using @Observable on Linux with Swift 6.2.3 fails with macro expansion errors.
Environment
- OS: Arch Linux (kernel 6.18.3-arch1-1)
- xtool: 1.16.1
- Swift: 6.2.3 (swift-6.2.3-RELEASE)
- iOS SDK: darwin (iOS 18.5 from Xcode)
Error
macro expansion @Observable:16:26: error: declaration name 'shouldNotifyObservers' is not covered by macro 'Observable'
The generated code shows mangled unique names:
private nonisolated func shouldNotifyObservers<$s6A_LIST22JourneysContentManager10ObservablefMm_6MemberfMu1_>(...)
Root Cause Analysis
The @Observable macro uses context.makeUniqueName("Member") for generic parameters. On Linux, these generate names starting with $ that look like Swift symbol manglings, which the compiler then rejects.
The macro declaration in Swift properly declares shouldNotifyObservers in its names: parameter:
@attached(member, names: named(_$observationRegistrar), named(access), named(withMutation), named(shouldNotifyObservers))
But the generated code uses unique mangled names that aren't being accepted.
Related Issues
Question
Is this a known limitation? Is there a workaround like using a different Swift version or toolchain configuration?
Description
Building any project using
@Observableon Linux with Swift 6.2.3 fails with macro expansion errors.Environment
Error
The generated code shows mangled unique names:
Root Cause Analysis
The
@Observablemacro usescontext.makeUniqueName("Member")for generic parameters. On Linux, these generate names starting with$that look like Swift symbol manglings, which the compiler then rejects.The macro declaration in Swift properly declares
shouldNotifyObserversin itsnames:parameter:@attached(member, names: named(_$observationRegistrar), named(access), named(withMutation), named(shouldNotifyObservers))But the generated code uses unique mangled names that aren't being accepted.
Related Issues
Question
Is this a known limitation? Is there a workaround like using a different Swift version or toolchain configuration?