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.
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"),
]
Install using CocoaPods by adding this line to your Podfile
:
use_frameworks!
target 'MyApp' do
pod 'CSSystemInfoHelper', '~> 2.0'
end
import CSSystemInfoHelper
print("\(CSSystemInfoHelper.shared.systemInfo.string)"
let networkInterfaces = CSSystemInfoHelper.shared.networkInterfaces!
for nif in networkInterfaces {
print("\(nif.name): \(nif.address) (\(nif.familyName))")
}
uname(3)
let systemInfo = h.systemInfo!
print(systemInfo.string)
print(systemInfo.versionString)
print(CSSystemInfoHelper.shared.memoryUsageString)
print(CSSystemInfoHelper.shared.memoryPhysicalFootprintString)
print(CSSystemInfoHelper.shared.platformUUID)
Check out the complete documentation on CocoaDocs.
link |
Stars: 5 |
Last commit: 2 years ago |
Released on Tuesday, June 22, 2021. Silences an outstanding compiler warning
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.
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
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
platformUUID
property is now only available on macOS 3d9127a
memoryPhysicalFootprint
and memoryPhysicalFootprintString
properties to CSSystemInfoHelper
, that extract and format the phys_footprint
member of the vm_task_info
struct. 2c6943f
systemInfo
being computed on demand, instead of cached on the first call.Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics