Alamofire on Linux: Getting Closer; Now With Bonus Windows Support!

Previously: Alamofire on Linux.

With the release of Swift 5.4 it looks like Foundation on Linux is in a good enough place to make an Alamofire port much easier than it was in the past. Since @SlaunchaMan was recently abducted by the mothership and because the changes are much simpler now, this work has been redone and resides on the feature/linux-support branch and is tracked as PR #3446.

I've tested an executable using the branch can successfully make a request on Linux. There are currently only a few remaining pieces of functionality that need to be replaced.

  • Stream.getBoundStreams doesn't exist in swift-corelibs-foundation.
  • MIME type detection to replace the use of UTTypeCreatePreferredIdentifierForTag and UTTypeCopyPreferredTagWithClass.
  • The NSURLSessionDownloadTaskResumeData key for URLError.userInfo doesn't exist in swift-corelibs-foundation.
  • URLAuthenticationChallenge handling is disabled pending a refactor to work around none of the Security types being available on Linux.

Surprisingly, that's it! I still need to port the test suite over, which will likely involve support test resources as well a getting a Linux build of the Firewalk test server, but we're closer than ever before.

If anyone tries this out, please report issues here and not on our GitHub, at least until we're officially shipped.

11 Likes

Thanks to work from @alex_taffe, this same PR now supports Windows as well!

Next steps include adding testing support for Linux (Windows testing is blocked by SwiftNIO / Vapor support) by porting our testing server and creating a deployment.

As for shipping, since full Windows support is pending, I'm tempting to ship both OSes with some sort of unverified support rating, which would be a first for Alamofire. At the least it would allow us to ensure we keep building as we build out new features (websocket support is coming) until we can get tests passing. What does the community think?

1 Like

I personally view having support that may be incomplete more important than having no support at all, but that’s just my two cents

I agree. It would help us start porting code to windows/linux and, who knows, maybe find some edge cases.

@Alejandro_Martinez The edge cases are extensive. Even ignoring APIs which aren't supported at all, there are other behavioral differences which makes porting the full test suite unlikely.

I've gotten the tests compiling on Linux, as well as our test server, but running the suite reveals crashes during auth challenges, strange behavioral differences, and other failures. So while we might be able to build the library there's no way we can support it on these other platforms. I think we're okay merging the changes as long as it can be made clear that we won't be providing support for the various issues that will inevitably come up. The community is welcome and encourage to triage these various issues and report the bugs on bugs.swift.org.

1 Like

This work has been merged. However, while buildable, Alamofire will be unsupported on Linux and Windows for the foreseeable future, as we aren't able to pass our test suite. If anyone would like to investigate the cause of those failures, feel free, but it's not a high priority for me.

1 Like
Terms of Service

Privacy Policy

Cookie Policy