Hi, I wonder what's the exact meaning of minimal macOS version of a macro package? Is is for macro code or the code it generates? I though it was the former, but my experiments show the latter is true.
Background: I'm using Xcode 15.0 on macOS 13.6, which can't be deployment target of Swift 5.9 specific code (but it's OK to build code on it). I find it's impossible to develop macro which generates Swift 5.9 specific code (e.g. init accessor) on it, because:
a) To generate Swift 5.9 specific code, I have to set minial macOS to v14
, otherwise there would be compile error.
b) If I set minimal macOS to v14
, the compile error is gone. However, there is following warning in macro declaration file, which indicate the macro module wasn't built successfully:
External macro implementation type 'DictionaryStorageMacroMacros.DictionaryStorageMacro' could not be found for macro 'DictionaryStorage()'
I know macro needs to be compiled and executed on host. Also it verifies the generated code is valid code. My intuition is that means it needs to build the code a macro generates rather than run it. If so, why generating Swift 5.9 specific code requires setting the minimal macOS to v14
? (Swift 5.9 can build code on macOS 13.6, it's just that it can't run them)
Also I know Observable
macro (more accurately, ObservationTrackedMacro
) generates init accessor. I wonder why I have no problem using it on my MBP? What's the difference? Thanks.