SwiftNIO 2

Announcing SwiftNIO 2

Now that Swift 5 has been released, we are very excited to also release SwiftNIO 2.0.0 for the brand new Swift 5 :rocket:.

First of all, a big thank you to the SwiftNIO community :purple_heart:. The SwiftNIO project is now just over one year old and your contributions have been amazing. We are so happy to see the awesome things you have built using SwiftNIO in its first year and can't wait for what's next. A special shout-out also to all those living on the NIO 2 branches as we were developing them, it was a huge help to have the code run in actual projects right after it was written.

The main theme of the SwiftNIO 2 release is a refinement of our APIs and taking advantage of the new features in Swift 5 such as the new UTF-8 String :sparkles:. In addition to these refinements in the core of SwiftNIO, there are two major changes that are we are most excited about:

  1. swift-nio-ssl now provides TLS (SSL) support without relying on your system's OpenSSL version. That allows much improved compatibility and makes SwiftNIO ready for future protocols that cannot be implemented without very up to date TLS libraries that Linux distributions often don't provide. That is achieved by vendoring BoringSSL inside the swift-nio-ssl SwiftPM package.
  2. swift-nio-http2 is now a pure-Swift implementation of the HTTP/2 protocol :rocket:. That means you can now use HTTP/2 with SwiftNIO without having the nghttp2 library installed on your system.

Besides being super cool to have a pure-Swift HTTP/2 implementation this also means that using SwiftNIO for your package is easier than ever as with Open/LibreSSL and nghttp2 we dropped two significant system dependencies.

To get started, check out the README. If you want to migrate your SwiftNIO 1 application or library, do check out the migration guide we prepared for you. If you don't want to migrate right now, or you can't because you want to continue supporting Swift 4, don't worry: SwiftNIO1 does work with Swift 5 just fine and there's no action required today or in the near future.

If you want to start using SwiftNIO 2 right now without further ado, please find below the correct SwiftPM dependencies for all the repositories in the SwiftNIO 2 family (yes, some of them have major version 1).

// 🚀
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),

// 🔐
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.0.0"),

// ⛑
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.0.0"),

// 2️⃣
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.0.0"),

// , for `platforms: [ .macOS(.v10_14), .iOS(.v12), .tvOS(.v12), ]`
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.0.0"),

Please feel free to reach out if you have any questions!

Thank you, the SwiftNIO team.



Congratulations to the team - great news :grinning:

1 Like

Good job, love the http2 part.

1 Like

It's my favourite part too, I'm very excited about it, not least because it puts the SwiftNIO community in charge of its own destiny. It is much easier for contributors to tweak and change things because the implementation is in a language they use every day. Over the next several months I expect to see a bunch of features land, but also an enormous amount of performance improvement as we invest in infrastructure to measure performance and start throwing brainpower at any perf issues we may have today.

Speaking of which, the more the community can hammer this stuff out, the faster it'll improve. We fixed a number of subtle bugs in the swift-nio-ssl stuff before 2.0 thanks to @tanner0101 picking it up early, as well as a number of HTTP/2 bugs thanks to people in the GRPC community.

With that in mind, @Helge_Hess1: if I were a betting man, I'd say that I bet that swift-nio-http2 doesn't work properly on Raspberry Pi. I wonder if we can find someone to help out with that work? :wink:


I'm going to update my Raspi Docker images for 5 soon (or is Raspi going to be covered by the new Swift 5 official images, @IanPartridge?). There is great news on that front as well: Swift 5 itself builds on 64-bit Raspi's with 0 patches required! Great job, I think mostly thanks to @futurejones. Since 64 bit Raspi works great for me, I don't think I'm going to back port to 32 bit.

But sure, I'm definitely going to checkout the new HTTP/2 support and let you know if it doesn't work ;-)


Amazing work! Congratulations on the release :)

1 Like

Awesome news! Congratulations :clap::clap:


Gratz! Awesome news! Already started migrating my projects :)

1 Like

I'm afraid Raspi won't be covered by the Swift 5 images, at least in the short term. When there are Raspi binaries on Swift.org - Download Swift we can revisit that.


Excellent! :muscle:

1 Like

FDBSwift can't celebrate more :D


BTW, I think you could elaborate more on ChannelError.connectFailed deprecation. I mean, it took me some time to figure out that it has been kinda replaced by NIOConnectionError.

FYI, @futurejones:

Just built SwiftNio 2 with Swift 5.0 release on AArch64 Ubuntu 16.04. All seems to be ok. All tests passing.


For those looking to see an implementation of the HTTP2 client side of things, we do that here, specifically APNSConnection.swift, in the Swift NIO 2 Apple push notification service implementation.


This sounds awesome and should be an official server side module!


Thanks Helge, the pitch is here.


Here’s the PR. Previously we had multiple different errors that could be thrown on connection failure, now it’s more unified and always uses NIOConnectionError. Did this lead to any issues for you?


Congrats team! My pet project OSCCore already embraced NIO 2.

1 Like