SwiftPackageIndex-Server
SwiftPackageIndex-Server copied to clipboard
plugin-only packages don’t build
swift-package-catalog
is a package that just vends a single plugin, Catalog
. this causes its Linux builds to fail (since it contains no buildable targets), and ironically, it also causes its iOS, watchOS, and tvOS builds to succeed, even though plugins don’t exist on those platforms!
I’ll let @finestructure handle the Linux case as he knows far more about that side of things, but I can chime in on the iOS/watchOS/tvOS issue.
I added your package to a test iOS project, and I think we’re doing the correct thing by flagging it as compatible because technically, it is! You can add the package and build an iOS project (and watchOS/tvOS, too) without any errors. It makes little sense to do that, but Xcode raises no issues if you do.
If you want to indicate that this package is incompatible, you’ll need to add something that deliberately breaks the build (with an #error
or similar) on those platforms. However, I just tried doing this using the following code, and it doesn’t break the build in Xcode:
#if os(iOS) || os(tvOS) || os(watchOS)
#error("This package is not compatible with iOS, tvOS, or watchOS.")
#endif
In fact, nothing I could do in that file, including inserting completely invalid code for all platforms, broke the build on iOS/tvOS/watchOS platforms. I guess that it doesn’t even compile that file as it knows it is only used by a plugin.
I'm not sure what we could do here. Here's another package that fails its SPM builds for that same reason: https://swiftpackageindex.com/MarcoEidinger/SwiftFormatPlugin
[builder] error: the package does not contain a buildable target
Both the SPM build on macOS and Linux share that issue. I guess package builds for plugin-only packages make very little sense. But I'm not sure how we could determine compatibility in this case.
We could exclude packages with "plugin only" products from build result reporting. Perhaps give them a different kind of display (no build matrix instead of all "?" of "X").
Not sure what the mechanism could/should be to determine what platforms they work on short concocting some mechanism to actually run the plugin in a project. That's pretty much infeasible at scale though...
what if you create an empty client package and target that depends on the plugin, and try building (without running) the client package?