Skip to content

Add FoundationURL trait - #118

Merged
guoye-zhang merged 5 commits into
apple:mainfrom
guoye-zhang:trait
Jun 1, 2026
Merged

Add FoundationURL trait#118
guoye-zhang merged 5 commits into
apple:mainfrom
guoye-zhang:trait

Conversation

@guoye-zhang

Copy link
Copy Markdown
Contributor

Add a default enabled trait "FoundationURL" that can be disabled for users who don't want Foundation dependencies. Also enable InternalImportsByDefault.

@guoye-zhang guoye-zhang added the 🆕 semver/minor Adds new public API. label May 8, 2026
Comment thread Package.swift Outdated
.library(name: "HTTPTypesFoundation", targets: ["HTTPTypesFoundation"]),
],
traits: [
"FoundationURL",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a description to this trait please

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@guoye-zhang

Copy link
Copy Markdown
Contributor Author

I'm wondering if there is way to disable a target (HTTPTypesFoundation) when the trait is off

@FranzBusch

Copy link
Copy Markdown
Member

I'm wondering if there is way to disable a target (HTTPTypesFoundation) when the trait is off

There is not right now. The way to do this is just #if guard the entire contents of the target.

@FranzBusch FranzBusch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing. Can we add a test that ensures that a resulting binary that builds without the trait will not link any of the Foundation modules. Similar to this https://github.com/apple/swift-openapi-runtime/blob/865bce04b31f9041ab56a3d565fb2f445198f0b5/.github/workflows/pull_request.yml#L90

Comment thread Package.swift
@guoye-zhang
guoye-zhang merged commit f14fbc0 into apple:main Jun 1, 2026
56 checks passed
@guoye-zhang
guoye-zhang deleted the trait branch June 1, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants