macOS system library in Swift

Related tags

Utility SystemKit
Overview

SystemKit

A macOS system library in Swift based off of libtop, from Apple's top implementation.

  • For an example usage of this library, see dshb, a macOS system monitor in Swift
  • For other system related statistics in Swift for macOS, see SMCKit

Requirements

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate SystemKit into your Xcode project using Carhage, specify it in your Cartfile:

github "beltex/SystemKit"

Run carthage update to build the framework and drag the built SystemKit.framework into your Xcode project. Don't forget to alter your Carthage building phase for macOS.

Example

Sample ouput from example.

// MACHINE STATUS

-- CPU --
  PHYSICAL CORES:  2
  LOGICAL CORES:   2
  SYSTEM:          10%
  USER:            17%
  IDLE:            71%
  NICE:            0%

-- MEMORY --
  PHYSICAL SIZE:   7.75GB
  FREE:            1.33GB
  WIRED:           866MB
  ACTIVE:          5.04GB
  INACTIVE:        516MB
  COMPRESSED:      0MB

-- SYSTEM --
  MODEL:           MacBookPro7,1
  SYSNAME:         Darwin
  NODENAME:        beltex.local
  RELEASE:         13.4.0
  VERSION:         Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014...
  MACHINE:         x86_64
  UPTIME:          6d 21h 4m 38s
  PROCESSES:       197
  THREADS:         967
  LOAD AVERAGE:    [3.18, 3.89, 3.99]
  MACH FACTOR:     [0.436, 0.385, 0.322]

-- POWER --
  CPU SPEED LIMIT: 100.0%
  CPUs AVAILABLE:  2
  SCHEDULER LIMIT: 100.0%
  THERMAL LEVEL:   Not Published

-- BATTERY --
  AC POWERED:      true
  CHARGED:         true
  CHARGING:        false
  CHARGE:          100.0%
  CAPACITY:        1675 mAh
  MAX CAPACITY:    1675 mAh
  DESGIN CAPACITY: 5450 mAh
  CYCLES:          646
  MAX CYCLES:      1000
  TEMPERATURE:     30.0°C
  TIME REMAINING:  0:45

References

License

This project is under the MIT License.

Comments
  • Handling kinfo_proc

    Handling kinfo_proc

    • Can't seem to handle kinfo_proc
    • See compiler bugs 2259, 2260 - https://github.com/practicalswift/swift-compiler-crashes
    • Doesn't seem currently possible, thus we use a bridging header, make the call in C, and return a simplified struct in the mean time

    Additional Refs

    • https://github.com/practicalswift/swift-compiler-crashes/pull/34
    • https://github.com/practicalswift/swift-compiler-crashes/pull/35
    bug 
    opened by beltex 2
  • Result of usageCPU doesn't update

    Result of usageCPU doesn't update

    Hi there, it looks that the result of a call to the usageCPU doesn't update the returned values. This my my fragment of code (99% identical to the documentation):

        var sys = System()
        let cpuUsage = sys.usageCPU()
    
        cpuUsageSystem.stringValue =  "\(Int(cpuUsage.system))%"
        cpuUsageUser.stringValue =  "\(Int(cpuUsage.user))%"
        cpuUsageIdle.stringValue =  "\(Int(cpuUsage.idle))%"
        cpuUsageNice.stringValue = "\(Int(cpuUsage.nice))%"
    
    opened by getangar 0
  • CpuUsage not updating

    CpuUsage not updating

    I'm running the example code in a swift UI app inside a 1sec timer. While I can see load and memory usage updating, the cpu usage remains constant- 7% system, 12% user and 81% idle. While the numbers are actually fluctuating, they only do so at the 5th digit.

    It looks a bit as if the raw OS counters are being exported, not the actual load?

    opened by andig 0
  • Installation issue

    Installation issue

    Carthage is giving me an error while installation as

    Skipped building SystemKit due to the error: Dependency "SystemKit" has no shared framework schemes

    P.S. I've tried with other projects and they are working fine.

    opened by SkrewEverything 7
  • Not showing correct battery charge

    Not showing correct battery charge

    I don't know if this is a bug or just me. But using the Battery method charge() doesn't seem to return the correct charge. It's about 5-6 percents lower than what it should be.

    screen shot 2016-06-29 at 23 27 47 screen shot 2016-06-29 at 23 28 45

    opened by pkrll 2
Releases(v0.0.5)
  • v0.0.5(Jun 15, 2015)

    • Updated to Xcode 6.3.2
    • Replace processCount() & threadCount() with processCounts()
    • This release is simply for the purpose of being a marker before the update to Swift 2.0 which will have breaking changes
    Xcode 6.3.2
    Build version 6D2105
    Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53)
    Target: x86_64-apple-darwin14.3.0
    
    Source code(tar.gz)
    Source code(zip)
  • v0.0.4(Mar 12, 2015)

  • v0.0.3(Feb 26, 2015)

  • v0.0.2(Feb 12, 2015)

    • New system functions
      • System.modelName()
      • System.uptime()
      • System.uname()
    • New power related functions:
      • System.CPUPowerLimit()
      • System.thermalLevel()
    • Added back some of the process related stuff, but still WIP
    • Internal cleanup
    • Completed:
      • #13: Test on OS X 10.10 (Yosemite)
      • #14: PPC support?
    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Jan 12, 2015)

Owner
iOS Developer.
null
Swift System, battery included.

System Extras A complimentary set of extensions to Swift System. Our goals are: Feel natural to use in conjunction to existing System APIs Provide mis

Daniel Duan 5 Oct 20, 2022
Mouse Finder is a fun replacement for the system Finder icon in the Dock.

Mouse Finder Mouse Finder is a fun replacement for the system Finder icon in the Dock. It mostly works exactly like the system icon, with one importan

Neil Sardesai 432 Dec 22, 2022
Drop-in replacement for system() in iOS programs

ios_system: Drop-in replacement for system() in iOS programs When porting Unix utilities to iOS (vim, TeX, python...), sometimes the source code execu

Nicolas Holzschuch 737 Dec 23, 2022
MetricTime is designed to be one universal timekeeping system that eliminates the hassle of calculating time since most of its convertions as simple as converting meters to centimeters

MetricTime MetricTime is designed to be one universal timekeeping system that eliminates the hassle of calculating time since most of its convertions

Adrian Edwards 4 Feb 10, 2022
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.

Mechanica A library of Swift utils to ease your iOS, macOS, watchOS, tvOS and Linux development. Requirements Documentation Installation License Contr

Alessandro 28 Aug 28, 2022
Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)

SwiftFoundation Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. Goals Provide a cross-platform in

null 620 Oct 11, 2022
This is a Swift package with support for macOS that allows to start Java Jar's with the default or a custom JVM.

Jar.swift jar runner for macos Jar.swift is created and maintaned with ❥ by Sascha Muellner. What? This is a Swift package with support for macOS that

Swift Package Repository 1 Nov 11, 2021
Hermes is a Swift 5 payload for macOS.

Hermes is a Swift 5 payload for macOS. This version currently supports Mythic 2.2.8 and will update as necessary. It will not work with Mythic 2.1 and lower.

Mythic Agents 71 Dec 6, 2022
Add “Launch at Login” functionality to your macOS app in seconds

LaunchAtLogin Add “Launch at Login” functionality to your macOS app in seconds It's usually quite a convoluted and error-prone process to add this. No

Sindre Sorhus 1.3k Jan 6, 2023
A macOS application displaying the thermal, voltage and current sensor values.

Sensors About A macOS application displaying the thermal, voltage and current sensor values. License Project is released under the terms of the MIT Li

Jean-David Gadina 82 Jan 3, 2023
macOS utility for converting fat-frameworks to SPM-compatible XCFramework with arm64-simulator support

xcframework-maker macOS utility for converting fat-frameworks to SPM-compatible XCFramework with arm64-simulator support. ?? Description make-xcframew

Dariusz Rybicki 312 Dec 22, 2022
Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wallpaper image

Change menu bar color in macOS Big Sur Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wal

Igor Kulman 876 Jan 5, 2023
A set of utilities (vmcli + vmctl) for macOS Virtualization.framework

VMCLI A set of utilities to help you manage VMs with Virtualization.framework Installation Prerequisites macOS Big Sur (11+) XCode.app installed # mak

Yifan Gu 771 Dec 24, 2022
SwiftyUpdateKit is a framework for iOS and macOS.

SwiftyUpdateKit is a framework for iOS and macOS. This framework supports for a user to update your app when new app version is released on the App Store.

Hituzi Ando 4 Aug 24, 2022
A simple macOS utility that can be used to control the behaviour of Bose QC35 Headphones straight from the menu bar.

bose-macos-utility A simple macOS utility that can be used to control the behaviour of Bose QC35 Headphones straight from the menu bar. Why Have you e

Łukasz Zalewski 11 Aug 26, 2022
Small app that checks focus status under macOS 12

infocus What Small app for Mac Admins that checks focus status under macOS 11 and 12 and can be used to add Do Not Disturb support to management scrip

Bart Reardon 12 Nov 8, 2022
Check for suspicious processes on macOS.

pschk Check for suspicious processes on macOS. Installation $ make $ sudo make install or $ brew tap x13a/tap $ brew install x13a/tap/pschk Usage USAG

lucky 3 Sep 3, 2022
A tiny macOS utility to foster sustainable OSS

SustainableOSS SustainableOSS is a status bar app for macOS that indexes the third-party dependencies your projects depend on, sorts them by usage, an

Tuist 0 Dec 14, 2021
Versions tracker for your iOS, macOS, and tvOS app

VersionTrackerSwift VersionTrackerSwift is a versions / builds tracker to know which version has been installed by a user. Usage In your ApplicationDe

Tom Baranes 82 Oct 5, 2022