Skip to content

Commit e282e5c

Browse files
committed
Expand support of Apple platforms
1 parent 5e5c541 commit e282e5c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/util/Platform.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package aws.smithy.kotlin.runtime.util
77

88
import aws.smithy.kotlin.runtime.InternalApi
9+
import kotlinx.coroutines.awaitAll
910

1011
public interface PlatformEnvironProvider :
1112
EnvironmentProvider,
@@ -58,6 +59,9 @@ public enum class OsFamily {
5859
Windows,
5960
Android,
6061
Ios,
62+
IpadOs,
63+
TvOs,
64+
WatchOs,
6165
Unknown,
6266
;
6367

@@ -67,6 +71,9 @@ public enum class OsFamily {
6771
Windows -> "windows"
6872
Android -> "android"
6973
Ios -> "ios"
74+
IpadOs -> "ipados"
75+
TvOs -> "tvos"
76+
WatchOs -> "watchos"
7077
Unknown -> "unknown"
7178
}
7279
}

runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/util/PlatformNative.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ internal actual object SystemDefaultProvider : PlatformProvider {
7474

7575
val sysName = utsname.sysname.toKString().lowercase()
7676
val version = utsname.release.toKString()
77-
val machine = utsname.machine.toKString() // Helps differentiate iOS/macOS
77+
val machine = utsname.machine.toKString().lowercase() // Helps differentiate Apple platforms
7878

7979
val family = when {
8080
sysName.contains("darwin") -> {
81-
if (machine.startsWith("iPhone") || machine.startsWith("iPad")) {
82-
OsFamily.Ios
83-
} else {
84-
OsFamily.MacOs
81+
when {
82+
machine.startsWith("iphone") -> OsFamily.Ios
83+
// TODO Validate that iPadOS/tvOS/watchOS resolves correctly on each of these devices
84+
machine.startsWith("ipad") -> OsFamily.IpadOs
85+
machine.startsWith("tv") -> OsFamily.TvOs
86+
machine.startsWith("watch") -> OsFamily.WatchOs
87+
else -> OsFamily.MacOs
8588
}
8689
}
8790
sysName.contains("linux") -> OsFamily.Linux

0 commit comments

Comments
 (0)