Skip to content

Commit 3b77f49

Browse files
committed
[SPARK-51490] Support iOS, watchOS, and tvOS
### What changes were proposed in this pull request? This PR aims to support `iOS`, `watchOS`, and `tvOS`. ### Why are the changes needed? `ProcessInfo.processInfo.userName` is not allowed in `iOS`, `watchOS`, and `tvOS` according to `Platform Compatibility` matrix. - https://swiftpackageindex.com/apache/spark-connect-swift ![Screenshot 2025-03-12 at 11 16 52](https://github.com/user-attachments/assets/ad67336b-71d9-4a35-8bab-84b7ea860bcd) ### Does this PR introduce _any_ user-facing change? No, the compilation fails on these OSs until now. ### How was this patch tested? Manual review. After this PR, `Platform Compatibility` should be updated at the next refresh. https://swiftpackageindex.com/apache/spark-connect-swift ### Was this patch authored or co-authored using generative AI tooling? No. Closes #13 from dongjoon-hyun/SPARK-51490. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 085c3ef commit 3b77f49

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/SparkConnect/SparkSession.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ public actor SparkSession {
4545
/// - userID: an optional user ID. If absent, `SPARK_USER` environment or ``ProcessInfo.processInfo.userName`` is used.
4646
init(_ connection: String, _ userID: String? = nil) {
4747
let processInfo = ProcessInfo.processInfo
48+
#if os(iOS) || os(watchOS) || os(tvOS)
49+
let userName = processInfo.environment["SPARK_USER"] ?? ""
50+
#elseif os(macOS) || os(Linux)
4851
let userName = processInfo.environment["SPARK_USER"] ?? processInfo.userName
52+
#else
53+
assert(false, "Unsupported platform")
54+
#endif
4955
self.client = SparkConnectClient(remote: connection, user: userID ?? userName)
5056
self.conf = RuntimeConf(self.client)
5157
}

0 commit comments

Comments
 (0)