Luminous

March 3, 2026 · View on GitHub

Luminous

A Swift library that gives you quick access to system information on iOS.

iOS Swift SPM License


Requirements

  • iOS 17+
  • Swift 6.0
  • Xcode 16+

Installation

Swift Package Manager

In Xcode: File → Add Package Dependencies, then enter:

https://github.com/andrealufino/Luminous

Or add it directly to Package.swift:

dependencies: [
    .package(url: "https://github.com/andrealufino/Luminous", from: "3.0.0")
]

Usage

All API is accessed through static properties and methods on nested structs under the Luminous namespace. No instantiation needed.

import Luminous

// Disk
let free = Luminous.Disk.freeSpace(in: .gigabytes)
let total = Luminous.Disk.totalSpaceInBytes

// Network
if Luminous.Network.isInternetAvailable {
    let expensive = Luminous.Network.isExpensive  // true on cellular/hotspot
}

// Hardware
let cores = Luminous.Hardware.processorsNumber
let model = Luminous.Hardware.modelIdentifier   // e.g. "iPhone16,1"
let thermal = Luminous.Hardware.thermalState    // ProcessInfo.ThermalState

// OS version comparison
let current = Luminous.Hardware.systemVersion
let ios18 = OperatingSystemVersion(majorVersion: 18, minorVersion: 0, patchVersion: 0)
if current >= ios18 { ... }

// Battery — requires @MainActor
let level = await MainActor.run { Luminous.Battery.level }   // Float? (0–100)
let state = await MainActor.run { Luminous.Battery.state }   // UIDevice.BatteryState

@MainActor properties

Battery, Hardware.Screen, and Hardware.Device access UIKit APIs and must be called on the main actor:

// In a @MainActor context (e.g. a SwiftUI view or view controller):
let brightness = Luminous.Hardware.Screen.brightness
let style = Luminous.Hardware.Device.userInterfaceStyle  // .light / .dark

// From a non-isolated context:
let brightness = await MainActor.run { Luminous.Hardware.Screen.brightness }

API Reference

Luminous.Application

PropertyTypeDescription
versionStringCFBundleShortVersionString (e.g. "3.0.0"); "" if absent
buildStringCFBundleVersion (e.g. "42"); "" if absent
completeAppVersionString"3.0.0 (42)"
bundleIdentifierString?Bundle identifier (e.g. "com.example.MyApp"); nil if absent
displayNameStringUser-visible app name; "" if absent

Luminous.Audio

PropertyTypeDescription
currentAudioOutputVolumeFloat?0.0–1.0; does not activate the audio session
secondaryAudioShouldBeSilencedHintBoolAnother app is playing non-mixable audio
isWiredHeadsetPluggedInBool3.5 mm / Lightning / USB-C wired headset
isAnyHeadphoneConnectedBoolWired, AirPods, or any Bluetooth audio device

Luminous.Battery@MainActor

PropertyTypeDescription
levelFloat?0–100; nil in Simulator
stateUIDevice.BatteryState.unknown / .unplugged / .charging / .full
isChargingBoolConvenience shorthand for state == .charging

Luminous.Disk

All size methods accept a UnitInformationStorage parameter (default: .gigabytes).

Property / MethodTypeDescription
totalSpaceInBytesInt64Raw total capacity
freeSpaceInBytesInt64Available space including purgeable content
usedSpaceInBytesInt64Used space in bytes
totalSpace(in:)DoubleTotal capacity in the given unit
freeSpace(in:)DoubleFree space in the given unit
usedSpace(in:)DoubleUsed space in the given unit
let gb = Luminous.Disk.freeSpace(in: .gigabytes)
let mb = Luminous.Disk.usedSpace(in: .megabytes)

Luminous.Hardware

Property / MethodTypeDescription
processorsNumberIntTotal processor count
activeProcessorsNumberIntActive processor count
physicalMemory(in:)DoublePhysical RAM in the given unit (default .gigabytes)
availableMemoryInBytesInt64Memory available to the process
availableMemory(in:)DoubleAvailable memory in the given unit (default .megabytes)
systemVersionOperatingSystemVersionComparable — use >=, <, etc.
uptimeTimeIntervalSeconds since last boot
isLowPowerModeEnabledBool
thermalStateProcessInfo.ThermalState.nominal / .fair / .serious / .critical
modelIdentifierStringHardware model string (e.g. "iPhone16,1")
isSimulatorBooltrue when running in the iOS Simulator

Luminous.Hardware.Screen@MainActor

PropertyTypeDescription
brightnessFloat0.0–1.0
isScreenMirroredBool
isZoomedBoolDisplay Zoom is active
nativeBoundsCGRectPhysical screen bounds in pixels
nativeScaleFloatPhysical screen scale
boundsCGRectLogical screen bounds in points
scaleFloatLogical screen scale
maximumRefreshRateInt60, 120, etc.

Luminous.Hardware.Device@MainActor

PropertyTypeDescription
identifierForVendorString?Vendor UUID
nameStringUser-assigned device name (e.g. "Andrea's iPhone")
orientationUIDeviceOrientationCurrent device orientation
systemNameStringOS name (e.g. "iPhone OS")
userInterfaceStyleUIUserInterfaceStyle.light / .dark / .unspecified

Luminous.Locale

PropertyTypeDescription
currentLanguageString?BCP 47 code (e.g. "en", "it")
currentTimeZoneTimeZoneCurrent time zone
currentTimeZoneNameStringIANA identifier (e.g. "Europe/Rome")
currentCountryString?ISO 3166-1 (e.g. "US", "IT")
currentCurrencyString?ISO 4217 (e.g. "USD", "EUR")
currentCurrencySymbolString?e.g. "$", "€"
usesMetricSystemBool
decimalSeparatorString?"." or ","

Luminous.Network

PropertyTypeDescription
isConnectedViaWiFiBool
isConnectedViaCellularBool
isInternetAvailableBoolAny satisfied path
isExpensiveBoolCellular or personal hotspot
isConstrainedBoolLow Data Mode is active
supportsIPv4Bool
supportsIPv6Bool

OperatingSystemVersionComparable

Luminous adds retroactive Equatable and Comparable conformance to Foundation's OperatingSystemVersion, enabling direct comparison operators:

let current = Luminous.Hardware.systemVersion
let ios18 = OperatingSystemVersion(majorVersion: 18, minorVersion: 0, patchVersion: 0)

if current >= ios18 {
    // iOS 18+ code path
}

Migrating from v2

Removed (no replacement)

APIReason
Luminous.CarrierCTCarrier deprecated since iOS 16.1; no reliable replacement
Luminous.Hardware.SensorsAll sensors have returned true on every iPhone since 2014
Luminous.Hardware.AccessoryMFi-only niche API with no broad use case
Luminous.Network.SSIDDead on iOS 13+ without entitlements and location access
Luminous.Application.clipboardStringTriggered iOS paste permission banner as a side-effect
Luminous.Hardware.Screen.snapshotOfCurrentViewUsed deprecated UIScreen API, no @MainActor safety
CocoaPods supportSPM is the standard; use Package.swift

Renamed / Moved

v2v3
Hardware.bootTimeHardware.uptime
Hardware.systemNameHardware.Device.systemName
Hardware.Accessory.isHeadsetPluggedInAudio.isWiredHeadsetPluggedIn

Replaced

v2v3
BatteryState (custom enum)UIDevice.BatteryState directly
MeasureUnit (custom enum)UnitInformationStorage from Foundation
SystemVersion structOperatingSystemVersion + Comparable extension (see above)
Disk.totalSpace(measureUnit:)Disk.totalSpace(in: UnitInformationStorage)
Disk.freeSpace(measureUnit:)Disk.freeSpace(in: UnitInformationStorage)
Disk.usedSpace(measureUnit:)Disk.usedSpace(in: UnitInformationStorage)
Hardware.physicalMemory(with:)Hardware.physicalMemory(in: UnitInformationStorage)
Audio.currentAudioOutputVolumeDouble?Audio.currentAudioOutputVolumeFloat? (no session activation side-effect)
Deprecated Disk string propertiesUse totalSpace(in:) / freeSpace(in:) / usedSpace(in:)

New in v3

APIDescription
Audio.isAnyHeadphoneConnectedIncludes AirPods and all Bluetooth audio
Hardware.thermalStateProcessInfo.ThermalState — nominal / fair / serious / critical
Hardware.modelIdentifierHardware model string, e.g. "iPhone16,1"
Hardware.availableMemoryInBytes / availableMemory(in:)Memory available to the process
Hardware.Screen.maximumRefreshRate60, 120, etc.
Hardware.Device.userInterfaceStyleLight / dark / unspecified
Network.isExpensiveTrue on cellular or personal hotspot
Network.isConstrainedTrue when Low Data Mode is active
Network.supportsIPv4 / supportsIPv6IP protocol support on current path
OperatingSystemVersion ComparableUse >=, <, == directly on OS version values

Author

Andrea Mario Lufino

License

Luminous is available under the MIT license. See the LICENSE file for details.