Skip to content

Commit 6ec2cdd

Browse files
authored
feat: add Android support (#673)
* Android support and CI * Add linux tests; update CI to copy snapshots * Update CI * Update CI * CI updates * Update CI * Update CI * Update CI * Attempt to remove crashing tests * Attempt to remove crashing tests * Attempt to remove crashing tests * Attempt to remove crashing tests * Attempt to remove crashing tests * Attempt to remove crashing tests * Attempt to remove crashing tests * Disable tests for Android and Linux
1 parent 86bc9e5 commit 6ec2cdd

24 files changed

+70
-16
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@ jobs:
101101
if: matrix.skip_release != '1'
102102
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild
103103

104+
linux_android:
105+
name: Linux and Android
106+
runs-on: ubuntu-24.04
107+
steps:
108+
- uses: actions/checkout@v4
109+
- name: "Remove IntegrationTests"
110+
run: rm -r Tests/IntegrationTests/*
111+
- name: "Build Swift Package on Linux"
112+
run: swift build
113+
- name: "Test Swift Package on Android"
114+
uses: skiptools/swift-android-action@v2
115+
with:
116+
# need to copy over the Tests folder because it contains __Snapshots__
117+
copy-files: Tests
118+
# tests are not yet passing on Android
119+
run-tests: false
120+
104121
# linux:
105122
# name: linux
106123
# strategy:

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/Auth/AuthClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public actor AuthClient {
109109
}
110110
)
111111

112-
Task { @MainActor in observeAppLifecycleChanges() }
112+
Task { @MainActor in await observeAppLifecycleChanges() }
113113
}
114114

115115
#if canImport(ObjectiveC) && canImport(Combine)

Sources/Auth/Internal/Keychain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(Windows) && !os(Linux)
1+
#if !os(Windows) && !os(Linux) && !os(Android)
22
import Foundation
33
import Security
44

Sources/Auth/Storage/AuthLocalStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public protocol AuthLocalStorage: Sendable {
77
}
88

99
extension AuthClient.Configuration {
10-
#if !os(Linux) && !os(Windows)
10+
#if !os(Linux) && !os(Windows) && !os(Android)
1111
public static let defaultLocalStorage: any AuthLocalStorage = KeychainLocalStorage()
1212
#elseif os(Windows)
1313
public static let defaultLocalStorage: any AuthLocalStorage = WinCredLocalStorage()

Sources/Auth/Storage/KeychainLocalStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(Windows) && !os(Linux)
1+
#if !os(Windows) && !os(Linux) && !os(Android)
22
import Foundation
33

44
/// ``AuthLocalStorage`` implementation using Keychain. This is the default local storage used by the library.

Sources/Realtime/Deprecated/RealtimeClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public class RealtimeClient: PhoenixTransportDelegate {
131131
/// must be set before calling `socket.connect()` in order to be applied
132132
public var disableSSLCertValidation: Bool = false
133133

134-
#if os(Linux) || os(Windows)
134+
#if os(Linux) || os(Windows) || os(Android)
135135
#else
136136
/// Configure custom SSL validation logic, eg. SSL pinning. This
137137
/// must be set before calling `socket.connect()` in order to apply.

Sources/Supabase/SupabaseClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public final class SupabaseClient: Sendable {
131131
options.global.session
132132
}
133133

134-
#if !os(Linux)
134+
#if !os(Linux) && !os(Android)
135135
/// Create a new client.
136136
/// - Parameters:
137137
/// - supabaseURL: The unique Supabase URL which is supplied when you create a new project in your project dashboard.

Sources/Supabase/Types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public struct SupabaseClientOptions: Sendable {
138138
}
139139

140140
extension SupabaseClientOptions {
141-
#if !os(Linux)
141+
#if !os(Linux) && !os(Android)
142142
public init(
143143
db: DatabaseOptions = .init(),
144144
global: GlobalOptions = .init(),
@@ -155,7 +155,7 @@ extension SupabaseClientOptions {
155155
}
156156

157157
extension SupabaseClientOptions.AuthOptions {
158-
#if !os(Linux)
158+
#if !os(Linux) && !os(Android)
159159
public init(
160160
redirectToURL: URL? = nil,
161161
storageKey: String? = nil,

Sources/TestHelpers/MockExtensions.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ extension Mock {
2222
line: UInt = #line,
2323
column: UInt = #column
2424
) -> Self {
25+
#if os(Linux) || os(Android)
26+
// non-Darwin curl snapshots have a different Content-Length than expected
27+
return self
28+
#endif
2529
var copy = self
2630
copy.onRequestHandler = OnRequestHandler {
2731
assertInlineSnapshot(

0 commit comments

Comments
 (0)