Coder Social home page Coder Social logo

vsanthanam / networkreachability Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 6.0 20.18 MB

Modern Network Reachability in Swift using Structured Concurrency

Home Page: https://reachability.tools

License: MIT License

Swift 98.27% Shell 1.73%
swift async await reachability structured-concurrency ios macos tvos spm xcode

networkreachability's Introduction

NetworkReachability



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.

Installation

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.

Usage & Documentation

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.

Documentation

Additional installation instructions are available on the Swift Package Index

License

NetworkReachability is available under the MIT license. See the LICENSE file for more information.

networkreachability's People

Contributors

vsanthanam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

networkreachability's Issues

Example Code Documentation Error in func updateReachability()

Describe the bug

At this link in the docs under Retrieving the current network path -> Closurs
the following example code is missing a ')' and will not compile.

func updateReachability() {
    NetworkMonitor.networkPath(completionHandler: { (path: NWPath) in 
        // Do something with `path`
    }
}

The code should be

func updateReachability() {
        NetworkMonitor.networkPath(completionHandler: { (path: NWPath) in
            // Do something with `path`
        }) // <--- this parenthesis is missing.
}

or just

func updateReachability() {
        NetworkMonitor.networkPath() { (path: NWPath) in
            // Do something with `path`
        }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.