How to get the current OS name and version in Swift

1 Answer

0 votes
import Foundation

let processInfo = ProcessInfo.processInfo

// Get detailed OS version information
let osVersion = processInfo.operatingSystemVersion

print("Operating System: macOS/iOS")
print("Major Version: \(osVersion.majorVersion)")
print("Minor Version: \(osVersion.minorVersion)")
print("Patch Version: \(osVersion.patchVersion)")

 
 
/*
run:

Operating System: macOS/iOS
Major Version: 5
Minor Version: 15
Patch Version: 0
 
*/

 



answered Mar 28, 2025 by avibootz

Related questions

1 answer 99 views
1 answer 101 views
1 answer 105 views
1 answer 110 views
1 answer 73 views
1 answer 92 views
3 answers 109 views
...