Skip to content
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

Import FoundationEssentials instead of Foundation when available #159

Merged
merged 2 commits into from
Oct 9, 2024
Merged

Import FoundationEssentials instead of Foundation when available #159

merged 2 commits into from
Oct 9, 2024

Conversation

Cyberbeni
Copy link
Contributor

Removing Foundation dependency on non-Apple platforms allows us to significantly reduce the size of the build product when using the Swift Static Linux SDK.

Hello world docker image depending on mqtt-nio went from 169MB to 85MB.

Related PR in one of the dependencies: apple/swift-nio-transport-services#209

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.12%. Comparing base (e02e237) to head (e826c91).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
Sources/MQTTNIO/MQTTPacket.swift 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #159      +/-   ##
==========================================
- Coverage   79.07%   78.12%   -0.96%     
==========================================
  Files          22       22              
  Lines        2518     1979     -539     
==========================================
- Hits         1991     1546     -445     
+ Misses        527      433      -94     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adam-fowler
Copy link
Collaborator

Can you fix the validation issue here. Ideally you'd just run swiftformat but I haven't updated the version of swiftformat in a while so you might get a load of unrelated changes.

Instead just reorder the FoundationEssentials and Dispatch imports

Copy link
Collaborator

@adam-fowler adam-fowler left a comment

Choose a reason for hiding this comment

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

I haven't had a chance to investigate how using Foundation vs FoundationEssentials affects a library but this looks good.

@adam-fowler adam-fowler merged commit ac20cd5 into swift-server-community:main Oct 9, 2024
9 of 11 checks passed
@Cyberbeni
Copy link
Contributor Author

This video gives a good explanation: https://youtu.be/wn6C_XEv1Mo

@Cyberbeni
Copy link
Contributor Author

@adam-fowler If you want I can open a PR that adds SwiftFormat to Package.swift and updates validate.sh to use it as an SPM plugin for formatting locally and install the version from Package.resolved with caching (so repeated runs are faster) in the GitHub workflow.

The only difference would be that Package.swift (and other swift files not in Sources/Tests) can't be formatted when the formatter is an SPM plugin.

mint uses an unsafe method for running scripts, so I usually recommend against using it: yonaskolb/Mint#227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants