Swiftpack.co - thecatalinstan/CSSystemInfoHelper as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by thecatalinstan.
thecatalinstan/CSSystemInfoHelper 2.0.1
A utility library for getting system info, meant to provide a safe and straightforward way of accessing system information only available through C APIs.
⭐️ 5
🕓 2 years ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/thecatalinstan/CSSystemInfoHelper.git", from: "2.0.1")

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.

GitHub

link
Stars: 5
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

2 years ago

Released on Tuesday, June 22, 2021. Silences an outstanding compiler warning

New in version 2.0.0 (06/22/2021)

Released on Tuesday, June 22, 2021. This release introduces SPM support, extends and refactors the info interface, removes caching of most information snippets retrieved and improves overall code quality and test coverage.

Important! This release breaks API compatibility in a number of ways, so please read the changes below carefully, before upgrading an existing installation, as this may require some refactoring.

Changed

  • Deprecate AllIPAddresses and IPAddress in favor of a new property named networkInterfaces which now returns an array of CSNetworkInterface objects. This array now also contains IPv6 interfaces, as well as IPv4. 898069b
  • The systemInfo dictionary has been converted to a class where the previous keys are now instance properties. The systemInfoString and systemVersionString are now instance properties of the CSSystemInfo object, string and versionString respectively. b156e26
  • The platformUUID property is now only available on macOS 3d9127a

Added

  • Added the memoryPhysicalFootprint and memoryPhysicalFootprintString properties to CSSystemInfoHelper, that extract and format the phys_footprint member of the vm_task_info struct. 2c6943f

Closed Issues

  • Issue #1 is closed as a result of systemInfo being computed on demand, instead of cached on the first call.

Improvements

  • Adds Swift Package Manager support. 1291d76
  • The project now generates one multi-platform target, instead of multiple platform-specific targets. 1e82472

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics