Skip to content

Swift library that simplifies getting information about your network interfaces and their properties, both for iOS and OS X.

License

Notifications You must be signed in to change notification settings

artifice-industries/swift-netutils

 
 

Repository files navigation

NetUtils for Swift

Swift Version 4 Swift Version 5 CocoaPods Version Badge License Badge Supported Platforms Percentage Documented Badge Carthage compatible Swift Package Manager compatible Swift Build Xcode Build Join the chat at https://gitter.im/NetUtils-for-Swift/Lobby

Swift library that simplifies getting information about your network interfaces and their properties, both for iOS, macOS and Linux. This library is a wrapper around the BSD APIs like getifaddrs, to make it easy to use them from Swift.

Recommended way of integrating this library on macOS or iOS is using CocoaPods: https://cocoapods.org/pods/NetUtils. On Linux I recommend using the Swift Package Manager.

This library works with both Swift 4 and Swift 5.

Background Info

Some system APIs you can simply use from Swift, but others you cannot. The difference is that some are made available as a module, and some are not. The APIs around network interfaces are not exposed as a module, which means that you cannot use them from Swift without defining a module for them yourself. I documented this problem extensively in a blog post.

Installation

This library can be installed via CocoaPods, Carthage and Swift Package Manager.

Usage

This module contains only one class: Interface. This class represents a network interface. It has a static method to list all interfaces, somewhat surprisingly called allInterfaces(). This will return an array of Interface objects, which contain properties like their IP address, family, whether they are up and running, etc.

Please note that both IPv4 and IPv6 interfaces are supported.

License

This project is released under the MIT license.

About

Swift library that simplifies getting information about your network interfaces and their properties, both for iOS and OS X.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 82.9%
  • Shell 10.7%
  • Objective-C 5.1%
  • Ruby 1.3%