Macros: Xcode 15 and SwiftPM difference of opinions

I have published a library for third parties to use that includes some macros.

My users are struggling to use it because there are two different sets of results between Xcode and SwiftPM.

The sample here:

https://tirania.org/tmp/sample-godot.tar.gz

The above will compile and run if you use "swift build", but if you open that package with Xcode, and try to build it, you will get instead this error:

error: Swift package target 'SwiftGodot' is linked as a static library by 'a' and 'SwiftGodot', but cannot be built dynamically because there is a package product with the same name.

The fix for Xcode is to replace the dependencies line from this:

dependencies: ["SwiftGodot", .product (name: "SwiftGodotMacros", package: "SwiftGodot")],

to this:

dependencies: ["SwiftGodot"],

But if you do this, then SwiftPM produces the following error:

Sources/a/a.swift:8:7: error: external macro implementation type 'SwiftGodotMacroLibrary.GodotMacro' could not be found for macro 'Godot()'
Sources/SwiftGodotMacros/MacroDefs.swift:20:14: note: 'Godot()' declared here
public macro Godot() = #externalMacro(module: "SwiftGodotMacroLibrary", type: "GodotMacro")

1 Like

I think you were able to solve this in Move macro definitions into SwiftGodot target by tishin · Pull Request #150 · migueldeicaza/SwiftGodot · GitHub, is that correct?