-
Notifications
You must be signed in to change notification settings - Fork 174
Adopt FoundationEssentials instead of Foundation where available #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Mechanically replace `import Foundation` with `import FoundationEssentials`
Thanks for this! This is a worthwhile change but we have to be careful with merging it, as it requires a semver major due to Swift’s “leaky” imports. |
hm, not sure I follow. Are you saying, |
It doesn’t make the full API available, but it makes some things available. An example of one such problem is available at https://forums.swift.org/t/pitch-fixing-member-import-visibility/71432. The Swift team consider this a bug, and I agree, but our semver policies take the language as it is, not as it is intended to be. So this will require us to burn a major. The good news is that a) this will be a “cheap” major, as most codebases won’t be affected and so they can use a both-major range, and b) we have to do one anyway. So we’ll definitely make this change, I just wanted to clarify that it won’t be immediately merged. |
@Lukasa would a package trait help us here? |
Not really, the impending major is enough. |
Use
FoundationEssentials
if available.Checklist
If you've made changes to
gyb
files.script/generate_boilerplate_files_with_gyb
and included updated generated files in a commit of this pull requestMotivation:
Would be great that packages that depend on
swift-crypto
can be built without linking fullFoundation
.Modifications:
This patch simply replaces
import Foundation
with a conditionalimport FoundationEssentials
.In some files this also required to explicitly import the C standard lib.
Maybe we could follow the same approach as in https://github.com/swiftlang/swift-tools-support-core/blob/main/Sources/TSCLibc/libc.swift and add an internal module that abstracts this import dance in a single place.
Result:
After this change the package should only depend on
FoundationEssentials
.