I'm working on a cross platform codebase where my principle development is being done on macOS in SPM. Things are going fairly smoothly, but on a few occasions I've discovered issues in our usage of Foundation once I start testing my code on Linux. Is there a way to "opt out" of apple's foundation implementation on macOS (at least in debug and or test builds) to help catch these issues earlier?
The most effective way I've found to catch that sort of issue is with a CI that just double-checks by building and testing with a Linux container or VM instead. YMMV - not sure if that's an option for you or not.
Since it's integrated into the compiler, SwiftSyntax has a unit test that verifies that only a precise set of libraries are linked into its targets. Would adapting something like that to assert that Foundation isn't linked work for you?
I'm trying to think through how that might work, because linking foundation is fine... it's the differences between apple's foundation and the swift community one. (The most recent thing that bit me was FoundationXML being split out). None of these things are horribly painful to fix once the CI pipeline catches them... but it's a fairly constant source of churn in my git history. My hope was that I could force SPM to use the community Foundation while building on macOS as well.
Yea, it seems CI is the best course of action at the moment.
I've been following the new foundation conversation, but I don't see how this will improve the situation at all. There will still be two sources of truth, one on macOS and one everywhere else correct? Or is swift going to target the OSS version on all platforms?
It sounds like the intention is for the new open source, Swift implementation of Foundation to be used on all platforms. If Apple can figure out the binary compatibility on their platforms at least. And I wouldn't expect it any time soon.