NetworkReachability is a replacement for Apple's SystemConfiguration Network Reachability APIs. Because these APIs were originally written in C, they are quite old and cumbersome to use from Swift. In 2018, Apple added the Network framework which introduced the NWPathMonitor
class. This API addressed some of the problems with SCNetworkReachability
, but was still cumbersome to integrate into many commonly used app patterns. NetworkReachability wraps both these APIs in easy to use Swift wrappers with similar interfaces and features that will be familiar to most iOS developers. Using NetworkReachablity, you can easily integrate reachability observation into your app's pipeline using just a few lines of code.
NetworkReachability supports synchronous reachability queries, as well as constant asynchronous reachability observation via the following mechanisms:
NetworkReachability supports RxSwift bindings with an optional additional package: NetworkReachabilityRxSwift. This optional package exists so that you can safely depend on NetworkReachability without also depending on RxSwift if you don't need to. NetworkReachability itself has no non-apple dependencies.
NetworkReachability is currently distributed exclusively through the Swift Package Manager.
To add NetworkReachability as a dependency to an existing Swift package, add the following line of code to the dependencies
parameter of your Package.swift
file:
dependencies: [
.package(url: "https://github.com/vsanthanam/NetworkReachability.git", from: "1.0.0")
]
To add NetworkReachability as a dependency to an Xcode Project:
- Choose
File
→Add Packages...
- Enter package URL
https://github.com/vsanthanam/NetworkReachability.git
and select your release of choice.
Other distribution mechanisms like CocoaPods or Carthage may be added in the future.
NetworkReachability's documentation is built with DocC and included in the repository as a DocC archive. The latest version is hosted on GitHub Pages and is available here.
Additional installation instructions are available on the Swift Package Index
NetworkReachability is available under the MIT license. See the LICENSE file for more information.