Swift Package Index

SwiftIP

https://github.com/Samasaur1/SwiftIP.git

A library to help with getting IP addresses in Swift.


Compatibility

  • v2.2.0 and master
    5.3
    5.2
    5.1
    5.0
    4.2
  • v2.2.0 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS

SwiftIP

A library to help with getting IP addresses in Swift.

Installing

Add the following to your Package.swift:

.package(url: "https://github.com/Samasaur1/SwiftIP.git", from: "2.0.0"),

Or use Ice:

$ ice add SwiftIP

Usage

The documentation is available here: https://samasaur1.github.io/SwiftIP/

Effectively, however, you do this:

import SwiftIP

guard let localIP = IP.local() else {
    fatalError("Could not find local IP")
}

let publicIP: String? = IP.public()

print("Local IP: \(localIP); public IP: \(publicIP ?? "Not connected")")