SwiftPM and it's associated command line tools (
swift run etc) currently work across all the platforms that SwiftPM supports. However the behaviour of those tools is different across different platforms - it's the same on all platforms apart from macOS. For example on macOS,
swift test uses the Objective-C runtime to discover tests.
swift build builds against the Objective-C Foundation runtime instead of using
corelibs-foundation. This makes writing cross platform code difficult and prone to errors. For example, when developing on macOS you might use a Foundation API that doesn't work or has bugs on Linux. And even if you have a test for it on Linux, you have to ensure it runs on Linux because you can't check that on macOS.
I propose two initial things:
swift teston macOS should use the same test discovery features as the other platforms. This should ensure that when developing on macOS, you make sure your tests run as they would on other platforms/. To me this seems like a fairly simple win without any major downsides (though I'm sure there are some!).
swift runshould use
corelibs-foundation. This one is likely to cause more pain and I'm sure there are plenty of things that could block this. One issue I can immediately see is that when running a binary compiled with
swift buildon macOS I assume it uses the bundled Swift runtime in the OS as there are no static executables on macOS. Changing this to use corelibs-foundation is likely very hard. But would be interesting to hear if there are approaches that would work.
Overall, I think standardising the development flow of Swift packages across platforms would be beneficial to the language and make it easier to develop for.