aiReachability is an iOS micro framework for gathering network state for cellular and wi-fi connections.
This framework is a wrapper around the NWPathMonitor
class from Apple's Network
library and aims to be a simple example on how to gather network state, using native APIs.
- Swift 5.1
- Xcode 11
- iOS 12
- Gather both wifi and cellular network state synchronosly
- Unit Tests
- While using the simulator, sometimes when a network state change occurs it's not correctly relayed to the hosting app. This does not occur when using a real device.
Just add the following line to your PodFile
:
pod 'aiReachability'
And then run the following command on the terminal:
pod install
- Carthage
Just add the entry to your Cartfile
:
github "aiFigueiredo/aiReachability"
And then run the following command on the terminal:
carthage update
Add the package to your Package.swift
file, under dependencies:
dependencies: [
.package(url: "https://github.com/aiFigueiredo/aiReachability.git", from: "1.0.0")
]
import aiReachability
// Instantiate NetworkMonitor Object
let networkMonitor = NetworkMonitor()
// Check wifi network state
print(networkMonitor.wifiState)
// Check cellular network state
print(networkMonitor.cellularState)
Feel free to contribute to this project by opening issues or opening pull requests.
aiReachability's available under the MIT license. See the LICENSE file for more information.