Contents

haven-apps/havendevice

A lightweight, zero-dependency Swift package that provides a complete snapshot of device and app information across all Apple platforms.

Overview

HavenDevice collects hardware, OS, app, locale, battery, screen, and system resource metadata into a single Codable struct. Call HavenDevice.current() from any async context and you're done.

let device = await HavenDevice.current()
print(device.modelName)      // "iPhone 16 Pro"
print(device.osName)         // "iOS"
print(device.batteryLevel)   // 72
print(device.thermalState)   // "nominal"

Use it for analytics payloads, feedback emails, diagnostics, crash reports, or any context where you need structured device info.

Installation

Add the package via Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/Haven-Apps/HavenDevice.git", from: "1.0.0")
]

Then add "HavenDevice" to your target's dependencies.

Platform Support

| Platform | Minimum Version | |----------|----------------| | iOS | 26.0 | | macOS | 26.0 | | watchOS | 26.0 | | tvOS | 26.0 | | visionOS | 26.0 |

Usage

import HavenDevice

let device = await HavenDevice.current()

// Encode to JSON for logging or network requests
let data = try JSONEncoder().encode(device)

Available Properties

Device Hardware

| Property | Type | Description | |-------------------|----------------|----------------------------------------------------------| | modelIdentifier | String | Raw hardware identifier (e.g. "iPhone17,3") | | modelName | String | Human-readable name (e.g. "iPhone 16 Pro") | | deviceFamily | DeviceFamily | .iPhone, .iPad, .mac, .appleWatch, etc. | | deviceName | String | User-assigned name (e.g. "Patrick's iPhone") | | isSimulator | Bool | Whether the process is running in the simulator |

Operating System

| Property | Type | Description | |-------------|----------|--------------------------------------------| | osName | String | "iOS", "macOS", "watchOS", etc. | | osVersion | String | Full version string (e.g. "26.0") |

App Information

| Property | Type | Description | |---------------|----------|----------------------------------------------------| | appName | String | Display name from Info.plist | | appVersion | String | Marketing version (e.g. "2.1.0") | | buildNumber | String | Build number (e.g. "42") |

Locale & Region

| Property | Type | Description | |------------------------|-----------|--------------------------------------------------| | language | String | Preferred language (e.g. "en-US") | | locale | String | Locale identifier (e.g. "en_US") | | region | String | Region code (e.g. "US") | | timeZone | String | Time zone identifier (e.g. "America/New_York") | | storefrontCountryCode| String? | App Store storefront (ISO 3166-1 Alpha-3) |

Screen

| Property | Type | Description | |---------------|-----------|------------------------------------------------| | screenScale | Double? | Display scale (e.g. 2.0 for Retina) | | screenWidth | Double? | Screen width in points | | screenHeight| Double? | Screen height in points |

Battery

| Property | Type | Description | |----------------|-----------|--------------------------------------------------------------------| | batteryLevel | Int? | Percentage (0-100). nil on tvOS, visionOS, or Macs w/o battery. | | batteryState | String? | "unplugged", "charging", "full", or "unknown" |

Battery info is available on iOS, watchOS, and macOS (MacBooks). On macOS, battery data is read via IOKit's IOPSCopyPowerSourcesInfo API. Desktop Macs without a battery (Mac mini, Mac Pro, iMac, Mac Studio) return nil.

System Resources

| Property | Type | Description | |------------------|----------|-----------------------------------------------| | thermalState | String | "nominal", "fair", "serious", "critical" | | isLowPowerMode | Bool | Whether Low Power Mode is enabled | | processorCount | Int | Active processor core count | | physicalMemory | UInt64 | Total RAM in bytes | | diskSpaceFree | Int64? | Available disk space in bytes | | diskSpaceTotal | Int64? | Total disk space in bytes |

Platform-Specific

| Property | Type | Description | |--------------------------------|-----------|-------------------------------------------------------| | identifierForVendor | String? | Vendor ID (iOS, tvOS, visionOS only) | | isJailbroken | Bool? | Jailbreak detection (iOS only) | | isDarkMode | Bool? | Dark Mode status (nil on watchOS) | | preferredContentSizeCategory | String? | Dynamic Type setting (nil on macOS, watchOS) | | supportsMultitasking | Bool? | Multitasking support (nil on macOS, watchOS) | | bundleIdentifier | String? | App bundle identifier | | copyright | String? | NSHumanReadableCopyright from Info.plist |

Privacy

This package collects no data. All information is gathered locally from system APIs (Bundle, ProcessInfo, UIDevice, IOKit, etc.) and returned as a struct for you to use however you choose. No network requests are made. No data is transmitted by this package.

License

HavenDevice is available under the BSD 3-Clause License. See LICENSE.md for details.

Package Metadata

Repository: haven-apps/havendevice

Default branch: main

README: README.md