Skip to content

Import System package when available #34

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

Merged
merged 2 commits into from
Mar 31, 2025
Merged

Import System package when available #34

merged 2 commits into from
Mar 31, 2025

Conversation

mattt
Copy link
Contributor

@mattt mattt commented Mar 30, 2025

The MCP SDK depends on the swift-system package for its FileDescriptor type. However, this creates incompatibilities when attempting to use this library with other libraries like this experimental Subprocess package (SF-0007) that conditionally import the swift-system package like so:

#if canImport(System)
    import System
#else
    @preconcurrency import SystemPackage
#endif

Trying to use both in the same project results in the following error:

Cannot convert value of type 'SystemPackage.FileDescriptor' to expected argument type 'System.FileDescriptor'

This PR replaces the existing instances of import SystemPackage with the same pattern, which should resolve the issue without any other side effects.

This PR also adds a isResourceTemporarilyUnavailable helper method to MCP.Error to eliminate the need for Client and Server to import System.Errno. Additional test coverage is provided.

See also apple/swift-system#60

@mattt mattt merged commit d55140b into main Mar 31, 2025
1 check passed
@mattt mattt deleted the mattt/import-system branch March 31, 2025 12:30
devyhan pushed a commit to devyhan/swift-sdk that referenced this pull request Apr 4, 2025
* Import System package when available

* Add isResourceTemporarilyUnavailable helper method to reduce number of imports of System / SystemPackage
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.

1 participant