Alamofire on Linux: Possible but not release ready!

I've put up a PR which boils down many of the foundational changes into a single set of changes. It should make it easier to ultimately support Linux while not affecting Alamofire now.

1 Like

Indeed. Linux NSValue simulates encodings for known types, though it cannot handle encoding C structs the way the Darwin version can. It works for numbers the way you’d expect, though!

I will take a look at the PR at some point this week. Thank you!

1 Like

The test suite has completed for the first time! With the probable Progress bug out of the way just 57 failures to investigate!

1 Like

It looks like the current issue is some inconsistent behavior of the Progress type between macOS and Linux. I’ve filed this as SR-12391 so we can track it separately.

Another additional wrinkle: with the upcoming DataStreamRequest we now use Stream.getBoundStreams, which is unimplemented in swift-corelibs-foundation. Luckily it should be easy to workaround.

I've conditionally compiled out the call to NSStream.getBoundStreams(withBufferSize:inputStream:outputStream:) for now, with an additional todo marked in the PR to see if that API can be made to work on Linux.

Another issue as I go through the test failures: it looks like URLSession on Linux isn’t calling methods for URLAuthenticationChallenge. I’ve created SR-12676 to track it.

1 Like

Apple has released a new security framework, called SwiftCrypto, with an open source implementation for Linux a while ago. It is also available on all Apple platforms as system framework but only with the newest OS version (iOS 13, macOS 10.15, etc.).
This could be a better alternative than OpenSSL on Linux.

Unfortunately SwiftCrypto isn't really suitable for the type of work Alamofire needs to do, like certificate pinning. Additionally, there isn't an alternate path for security challenges in URLSession, so there's not really a way to expose them on Linux unless Apple's willing to create Linux-only APIs, or a new API that can be used on all platforms. I'd prefer the second if it means being able to stop using the Security framework.

2 Likes