Skip to content

Commit 20450ac

Browse files
authored
feat: add user agent utils (#265)
1 parent 797ad2d commit 20450ac

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
public enum PlatformOperatingSystem: String {
9+
case windows
10+
case linux
11+
case iOS
12+
case macOS
13+
case watchOS
14+
case tvOS
15+
case unknown
16+
}
17+
18+
19+
public var currentOS: PlatformOperatingSystem {
20+
#if os(Linux)
21+
return .linux
22+
#elseif os(macOS)
23+
return .macOS
24+
#elseif os(iOS)
25+
return .iOS
26+
#elseif os(watchOS)
27+
return .watchOS
28+
#elseif os(Windows)
29+
return .windows
30+
#elseif os(tvOS)
31+
return .tvOS
32+
#else
33+
#error("Cannot use a an operating system we do not support")
34+
#endif
35+
}
36+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
public var swiftVersion: String {
9+
#if swift(>=5.6)
10+
#error("Cannot use a version of Swift greater than available. Please create a Github issue for us to add support for the version of Swift you want to use.")
11+
#elseif swift(>=5.5)
12+
return "5.5"
13+
#elseif swift(>=5.4)
14+
return "5.4"
15+
#elseif swift(>=5.3)
16+
return "5.3"
17+
#elseif swift(>=5.2)
18+
return "5.2"
19+
#elseif swift(>=5.1)
20+
return "5.1"
21+
#elseif swift(>=5.0)
22+
return "5.0"
23+
#else
24+
#error("Cannot use a version of Swift less than 5.0")
25+
#endif
26+
}
27+

0 commit comments

Comments
 (0)