Skip to content

A utility library for getting system info, meant to provide a safe and straightforward way of accessing system information only available through C APIs.

License

Notifications You must be signed in to change notification settings

thecatalinstan/CSSystemInfoHelper

Repository files navigation

Version Status Platform Carthage compatible MIT License

CSSystemInfoHelper

A utility library for getting system info, meant to provide a safe and straightforward way of accessing system information only available through C APIs.

I’ve used this library when making the criollo.io website in order to display the system the app is running on and various other projects over the years.

Getting Started

Installation using Swift Package Manager

Swift Package Manager

Add the package to your project's dependencies. If you have a Package.swift, it should look similar to this:

dependencies: [
    .package(name: "CSSystemInfoHelper", url: "https://github.com/thecatalinstan/CSSystemInfoHelper", from: "2.0.0"),
]

Installation through CocoaPods

Install using CocoaPods by adding this line to your Podfile:

use_frameworks!

target 'MyApp' do
  pod 'CSSystemInfoHelper', '~> 2.0'
end

In your Project

import CSSystemInfoHelper

print("\(CSSystemInfoHelper.shared.systemInfo.string)"

Examples

Getting IPv4 interfaces and addresses

let networkInterfaces = CSSystemInfoHelper.shared.networkInterfaces!
for nif in networkInterfaces {
	print("\(nif.name): \(nif.address) (\(nif.familyName))")
}

Getting System Info from uname(3)

let systemInfo = h.systemInfo!
print(systemInfo.string)
print(systemInfo.versionString)

Getting Human-readable Memory Usage

print(CSSystemInfoHelper.shared.memoryUsageString)
print(CSSystemInfoHelper.shared.memoryPhysicalFootprintString)

Getting the device UUID (macOS only)

print(CSSystemInfoHelper.shared.platformUUID)

What’s Next

Check out the complete documentation on CocoaDocs.

About

A utility library for getting system info, meant to provide a safe and straightforward way of accessing system information only available through C APIs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published