Is building for iOS/tvOS/watchOS necessary for "pure" Swift packages?

Hi Folks,

Given a Swift package that is intended to support all platforms (all apple platforms, linux, windows), is there any benefit to validating the package builds on iOS/tvOS/watchOS in addition to macOS? If a package builds successfully for a specific swift version on macOS using swift build, is it necessary to also verify it builds successfully using xcodebuild for each platform (using the -destination parameter)?
Assuming the package doesn't include any apple platform specific code (no uikit, no swiftui etc).

For context, I'm trying to determining the proper set of CI checks to install that instill full confidence while balancing resource usage. My gut says building for iOS/tvOS/watchOS is overkill and redundant but i couldn't explain why.

Even if you aren't importing any UI frameworks, if you're importing Foundation there's a lot of bits and pieces that are macOS-only. tvOS is missing some niche POSIX things (e.g. named pipes) which are available on the other three.

If your package doesn't particularly interact with OS functionality at all then you can probably get away with only testing macOS. Testing iOS as well is much higher value than testing tvOS/watchOS.

OTOH you may add one of those other platforms to the suite once you get the first bug report for that particular platform.

Yes.

You need to check that you're not forgetting any @available annotations, and that they all have the correct versions for each platform. There have also been occasions where the SDK had issues on certain platforms, requiring some slithers of functionality to be disabled so that the rest of the package continues to build.

For my packages, I found that the swiftpackageindex.com CI kept uncovering issues with specific platforms, so I recently updated my CI script to ensure package tests are executed on macOS for the latest Xcode release for each minor Swift version (5.5.3, 5.6.3, 5.7.2), and separately that it can build on all Apple platforms.

There's a bit of an issue with the script as written in that the latter part doesn't specify an Xcode version (and GitHub's default was 14.0.1 until recently, which was a problematic release). I'm planning to fix that soon and pin to a specific version. Executing tests on the iOS simulator is also probably not a bad idea.