OSInfo
Cross-platform Swift Package to determine OS name and version on which the app is running
Install / Use
/learn @MarcoEidinger/OSInfoREADME
OSInfo
Cross-platform Swift Package to report the operating system name and version on which the app is running
Key Aspects:
- a cross-platform API that works for iOS, iPadOS, watchOS, tvOS, visionOS, macOS, Mac Catalyst, Linux and Windows
- a universal API so that you don't need to worry about the various underlying APIs (
UIDevicevs.WKInterfaceDevicevs.ProcessInfo) - Dealing with the fact that iOS Apps on Mac and Mac Catalyst deal with two versions, the macOS version the app is running on (or targeting) and the iOS (support) version that macOS version corresponds with.
- The package default behavior is to obtain the underlying macOS version while still having the option to get the "iOS support version" if desired.
import OSInfo
// Example for running on iPhone
print(OS.current.name) // "iOS"
print(OS.current.version) // OperatingSystemVersion(majorVersion:16, minorVersion:1,patchVersion:0)
print(OS.current.version.description) // "16.1"
print(OS.current.displayVersion) // "Version 16.1 (Build 20B72)"
// Example for running on iPad
print(OS.current.name) // "iPadOS"
print(OS.current.version.description) // "16.1"
print(OS.current.displayVersion) // "Version 16.1 (Build 20B72)"
print(OS.current.iOSFamily) // true
// Example for running on Apple Watch
print(OS.current.name) // "watchOS"
print(OS.current.version.description) // "9.1"
print(OS.current.displayVersion) // "Version 9.1 (Build 20S75)"
// Example for running on Apple Vision (natively)
print(OS.current.name) // "visionOS"
print(OS.current.version.description) // "1.0"
print(OS.current.displayVersion) // "Version 9.1 (Build 20S75)"
// Example for running on Apple Vision (natively)
print(OS.current.name) // "visionOS"
print(OS.current.version.description) // "1.0"
print(OS.current.displayVersion) // "Version 1.0 (Build 21N5165g)"
print(OS.current.iOSFamily) // true
// Example for running on Apple Vision (Designed with iPad) with SDK "iOS"
print(OS.current.name) // "iPadOS"
print(OS.current.version.description) // "1.0"
print(OS().version.description) // "17.0"
print(OS.current.displayVersion) // "Version 1.0 (Build 21N5165g)"
print(OS.current.iOSFamily) // true
// Example for running on Mac
print(OS.current.name) // "macOS"
print(OS.current.version.description) // "13.0.1"
print(OS.current.displayVersion) // "Version 1.0 (Build 21N5165g)"
print(OS.current.appleFamily) // true
// Example for running as Mac Catalyst (or unmodified iOS app) on Mac
print(OS.current.name) // "macOS"
print(OS.current.version.description) // "13.0.1"
// -- alternative
print(OS(underlyingMacOS: false).name) // "iPadOS"
print(OS(underlyingMacOS: false).version.description) // "16.1"
print(OS.current.displayVersion) // "Version 13.0.1 (Build 22A400)"
// Example for running on Linux
print(OS.current.name) // Linux
print(OS.current.version) // 5.15
print(OS.current.displayVersion) // Ubuntu 22.04.1 LTS
print(OS.current.appleFamily) // false
Note:
OS.currentis equivalent toOS(underlyingMacOS: true)OS()is equivalent toOS(underlyingMacOS: false)
Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
