Skip to content

Add FoundationURL trait#118

Open
guoye-zhang wants to merge 4 commits into
apple:mainfrom
guoye-zhang:trait
Open

Add FoundationURL trait#118
guoye-zhang wants to merge 4 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.

Copy link
Copy Markdown
Member

@FranzBusch FranzBusch left a comment

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

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