Reachability news

Release 4.3.0 of Reachability.swift is live today, updating to Swift 4.2.

Available on GitHub or via CocoaPods

There’s also a new [reachability-swift] tag for StackOverflow questions -

More thoughts on Reachability.swift… and fame!

When I wrote Reachability.swift it was originally just to scratch a personal itch, plus a good Swift learning opportunity. As time went on though, other people began using it and it became apparent that having an open-source library is more than just putting the code out there and forgetting it.

Of course you have the pull requests to deal with, and often being busy with other things means these end up not being actioned as quickly as they probably should. And I need to keep an eye on StackOverflow, as people tend to raise issues there rather than on GitHub. Then there are the "my app doesn't work and I'll leave it to you to fix it for me" issues - 

Doesn't work
"Add Reachability.swift to my project and tried both closure code and notification code, but it does not work."

And there was Cocoapods and Carthage support. These aren't something I'd used prior to this project - but luckily the community that's growing up around Reachability.swift meant that there were people out there ready to help out.

What I really wasn't expecting though, was for the library to become popular. After a year or so, Apple still haven't released their own Swift version of Reachability, so it's looking like Reachability.swift is becoming the go-to library. It's been the feature of a little bites of cocoa tutorial, and mentioned on iOS Dev Weekly. The result of which, as of today, it's been forked 110 times and starred 1,138 times, which according to GitHub Awards, ranks me 4th in UK Swift developers and 92 worldwide. This week alone, it's been viewed on GitHub over 10,000 times, and cloned about 2,400 times. Fame at last!! ;)

Reachability.swift is on:


About a year ago, while moving Foto Flipper from Objective-C to Swift, I found there was no native Swift replacement for Apple's Reachability code.

For those not aware, this is an Objective-C wrapper, supplied by Apple, on the SystemConfiguration framework C functions, allowing the app to see the current network connectivity state (wifi, cellular or none) and be notified of any changes. This lets the app handle poor or no connectivity gracefully, rather than failing on web service calls with an obscure error message.

Apple's code has been around since 2008, using NSNotifictions to signal connectivity state changes. Since 2011, however, the go-to code to do this has been Tony Million's open-source Reachability, which added block callbacks, making handling updates much simpler.

Taking Tony's code as my inspiration, I wrote version 1 of Reachability.swift - although it soon became apparent that Swift 1.0 wasn't quite up to the task. Versions of Swift prior to 2.0 didn't allow closures to be converted to C function-pointers, meaning a SCNetworkReachabilityCallBack couldn't be set. The work around was to fire a timer every half second an check the reachability status then.

Finally, with Swift 2.0 and closure to C function-pointer support, Reachability.swift was completed, and now is a Cocoapod and as of today, supports Carthage.

Reachability.swift is on GitHub: