I know we don't usually talk Xcode here, but my hope is that someone with good SPM knowledge might help find a workaround. Tagged it off-topic just in case.
Right now (Xcode 13.3.1) attempts to build plugins for the target platform when plugins should only be built and run on the host platform (in my case macOS).
This means that something as basic as this won't work:
.executableTarget(
name: "DemoTool",
dependencies: [
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxParser", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
]
),
.plugin(
name: "DemoPlugin",
capability: .buildTool(),
dependencies: [
.target(name: "DemoTool"),
]
),
because SwiftSyntax
has a binary dependency to lib_InternalSwiftSyntaxParser.dylib
packed in a macOS-only xcframework
. When Xcode tries to compile DemoTool
for iOS/Sim you'll get something within the lines of:
While building for iOS Simulator, no library for this platform was found in / ../../_InternalSwiftSyntaxParser.xcframework
Now, I understand why Xcode wants to compile the executable target, but how can I prevent that? There seems to be no way of distinguishing between targets used by the plugin, always ran on the host platform and regular executable targets.
EDIT: I'm looking for a workaround that doesn't imply packing the tool as a binary dependency. That works, but sadly fails at the next step for other reasons (it seems Xcode doesn't fully support artifactbundle
yet)