We usually validate Swift Packages by calling swift build. But that command returns an error when used on valid swift packages that only contain binaryTarget.
Is there a good way to validate Swift packages that contain only binaryTargets?
(If not, it feels like swift build shouldn't return an error in those cases)
If it were me, I would add a test target that imports and exercises the binary targets, and use swift test. Otherwise you are not really validating anything, regardless of how swift build decides to classify a null build. (Though the current error does seem unintuitive to me. It is also inconsistent with packages containing only tests, which succeed in building nothing.)
I'd expect swift build to not return an error if a package (such as the one above) is valid. We don't need to create a test target to validate packages that contain source code (as we can just call swift build) so I'd hope the same would apply to these kinds of packages.
The difference between a source target and a binary one is that if you'd build the binary target on its own, the only thing that could happen is the binary gets copied into the build directory which isn't a useful operation and also wouldn't really validate a whole lot, except maybe the download. So it makes sense to have a test target to determine that the binary can be used successfully.
Note that also for source targets, just building the target itself without any tests does not validate that the target can be used by any client, it just validates that it can build.