Latest 0.0.1
Homepage https://github.com/yusuga/IP
License MIT
Platforms ios 9.0, requires ARC

IP for Swift

IP
IP
IP

Usage

Get Host name and IP

let host = try! Host.current()

Get routing table

let messages = try! System.routingTable()

Optional flags

let messages = try! System.routingTable(.availableNetwork)

Get network interfaces

let interfaces = try! Interface.all()

Get default gateway IP

let interface = interfaces[indexPath.row]
let message = try! System.retrieveDefaultGatewayMessage(from: interface)!
print(message.gateway!)
// Prints "IP(version: IPv4, address: "192.168.1.253", port: 0)"

Installation

CocoaPods

pod 'IP'

Latest podspec

{
    "name": "IP",
    "version": "0.0.1",
    "summary": "IPv4/IPv6 address, such as host, interface, routing table, default gateway.",
    "homepage": "https://github.com/yusuga/IP",
    "screenshots": "https://github.com/yusuga/IP/blob/master/.github/routing-table.png?raw=true",
    "license": "MIT",
    "authors": "Yu Sugawara",
    "social_media_url": "https://twitter.com/yusuga_",
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/yusuga/IP.git",
        "tag": "0.0.1"
    },
    "source_files": "IP/*.{swift}",
    "requires_arc": true,
    "preserve_paths": [
        "IP/libinfo/*",
        "IP/libnetwork/*"
    ],
    "libraries": [
        "info",
        "network"
    ],
    "pod_target_xcconfig": {
        "SWIFT_INCLUDE_PATHS": "$(PODS_ROOT)/IP/IP/libinfo $(PODS_ROOT)/IP/IP/libnetwork"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This