mirror of
https://github.com/apple/swift-crypto
synced 2026-11-22 04:30:39 +00:00
Use `FoundationEssentials` if available. <!-- Thanks for contributing to Swift Crypto! Before you submit your issue, please make sure you followed our checklist and check the appropriate boxes by putting an x in the [ ]: [x] --> ### Checklist - [x] I've run tests to see all new and existing tests pass (macOS and linux) - [x] I've followed the code style of the rest of the project - [x] I've read the [Contribution Guidelines](CONTRIBUTING.md) - [x] I've updated the documentation if necessary #### If you've made changes to `gyb` files - [ ] I've run `.script/generate_boilerplate_files_with_gyb` and included updated generated files in a commit of this pull request ``` bash .script/generate_boilerplate_files_with_gyb bash: .script/generate_boilerplate_files_with_gyb: No such file or directory ``` ### Motivation: Would be great that packages that depend on `swift-crypto` can be built without linking full `Foundation`. ### Modifications: This patch simply replaces `import Foundation` with a conditional `import 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`. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Cory Benfield <lukasa@apple.com>