How to get platform of the current device?

488 Views Asked by At

Is there a way to get the current platform of the device? I'm hoping for a better way than to do something like this:

let platform: String

#if os(iOS)
platform = "iOS"
#elseif os(watchOS)
platform = "watchOS"
#elseif os(tvOS)
platform = "tvOS"
#elseif os(macOS)
platform = "macOS"
#else
platform = "unknown"
#endif

Is there a better way to do this?

0

There are 0 best solutions below