Setup Swift-NIO for iOS, tvOS

Hi guys,

If you are familiar with Apple’s open-source repo on Github, you may know Swift NIO. One of Apple’s open source framework which deals with networking. The project is well implemented. But you know, the project is written not for iOS, tvOS. Its targets are for MAC, Ubuntu so far. Not sure if there will be any changes next time.

Swift Nio

I look over on Swift NIO, and I see it kind of potential. Written on the top of POSIX socket. Simple, lightweight. Some parts of its core are written in C or reuse C library. It even reuses the NGNIX’s HTTP parser in its core. I have found out that this parser is used widely in some well-known software and open sources. Some instances are NodeJs’s parser, IBM-Swift’s Kitura-net,… Some other languages also try to use this NGNIX’s parser, for example, Python parser,

I’m interested in a few parts in the Swift NIO project and literally, I would like to reuse some of them in the ios and TVos projects.

Well, nothing is impossible, right? I have done a DIY project which set up Swift-NIO for iOS/tvOS building.

How I setup it up

The setup is challenging. I’m not sure exactly the way Apple set up their project, but they are not relying on the XCode-based project. This makes sense because there is no XCode on Linux. If they use that way, it cannot compile on Linux.

But in this case, I’m going to setup it for iOS/tvOS (and maybe MAC, later on), no Linux here. So I’ll create a bunch of mini-projects and the main workspace. Some parts of Swift-NIO is in C. For those, I will have Objective-C projects. For the rest, they will be Swift project. The Swift projects eventually will import the Objective-C projects. That’s the overall idea for setting these up.

Outcome

The outcome so far is optimistic, I believe.

The project has been able to build for iOS, tvOS now. I have tried a simple demo with a simple HTTP server. The server runs well, takes the incoming request and return the response on both iOS/tvOS

Ok, check it out the project here swift-nio-ios-tvo and don’t forget to leave me a star in there. 🙂

What’s next?

let’s check out Compile and run Swift-NIO for MAC OS, Linux OS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s