Google Gemini: You are definitely not the first person to hit this. In fact, you have stumbled into one of the most notorious and painful "open secrets" of the current Swift Macro ecosystem. The current macro system essentially demands that you copy-paste utility code rather than share it via a library dependency.
the basic problem i have is we have about 4 packages that all have duplicated macro code. that is, the packages contain macros, and the macros in those packages have duplicated code for macro functionality like extracting string literals, emitting compiler diagnostics, et cetera.
we tried factoring out all of this duplicated code into a macro utilities package that is depended upon by the macros in each of the 4 client packages. this works with SwiftPM builds on macOS, but causes linker failures on linux, and when building with xcodebuild.
duplicate symbol 'SwiftSyntax.ExpressionSegmentSyntax.backslash.getter : SwiftSyntax.TokenSyntax' in:
/Users/runner/Library/Developer/Xcode/DerivedData/package-data-model-macos/Build/Products/Debug/SwiftSyntax.o
/Users/runner/Library/Developer/Xcode/DerivedData/package-data-model-macos/SourcePackages/prebuilts/swift-syntax/602.0.0/swiftlang-6.2.3.3.21-MacroSupport-macos_aarch64/lib/libMacroSupport.a[203](SyntaxNodesEF.swift.o)
things i tried:
- making the macro utilities library
type: .dynamic— this solves the linux linker issue, but not thexcodebuildfailures. it merely converts compile time linker failures to runtime crashes.
error: external macro implementation type 'OrdoEssentialsMacros.EnumerationMetadataMacro' could not be found for macro 'enumerationMetadata(enumerationIdentifier:)'; '/Users/runner/Library/Developer/Xcode/DerivedData/package-data-model-macos/Build/Products/Debug/OrdoEssentialsMacros' produced malformed response
- passing
-IDEPackageEnablePrebuilts=NOtoxcodebuild. this option seems to have no effect
the LLM and i are totally stumped now. the huge amount of duplicated syntax processing code between the 4 packages is unmaintainable, and we need a way to de-duplicate this logic that doesn’t break Xcode builds.