Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ body:
attributes:
label: Swift Version
description: What version of Swift are you using?
placeholder: ex. 5.10
placeholder: ex. 6.0
validations:
required: true

Expand Down
36 changes: 1 addition & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
name: xcodebuild (macOS latest)
runs-on: macos-15
strategy:
fail-fast: false
matrix:
command: [test, ""]
platform: [IOS, MACOS]
Expand Down Expand Up @@ -81,41 +82,6 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: lcov.info

macos-legacy:
name: xcodebuild (macOS legacy)
runs-on: macos-14
strategy:
matrix:
command: [test, ""]
platform: [IOS, MACOS, MAC_CATALYST]
xcode: ["15.4"]
include:
- { command: test, skip_release: 1 }
steps:
- uses: actions/checkout@v5
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: List available devices
run: xcrun simctl list devices available
- name: Cache derived data
uses: actions/cache@v4
with:
path: |
~/.derivedData
key: |
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
restore-keys: |
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
- name: Set IgnoreFileSystemDeviceInodeChanges flag
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
- name: Update mtime for incremental builds
uses: chetan/git-restore-mtime-action@v2
- name: Debug
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild
- name: Release
if: matrix.skip_release != '1'
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild

spm:
runs-on: macos-15
strategy:
Expand Down
34 changes: 16 additions & 18 deletions Examples/Examples/Profile/UserIdentityList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,30 +237,28 @@ struct UserIdentityList: View {
}
.id(id)
.navigationTitle("Linked Identities")
#if swift(>=5.10)
.toolbar {
ToolbarItem(placement: .primaryAction) {
if !providers.isEmpty {
Menu {
ForEach(providers) { provider in
Button {
Task {
await linkProvider(provider)
}
} label: {
Label(
provider.rawValue.capitalized,
systemImage: iconForProvider(provider.rawValue)
)
.toolbar {
ToolbarItem(placement: .primaryAction) {
if !providers.isEmpty {
Menu {
ForEach(providers) { provider in
Button {
Task {
await linkProvider(provider)
}
} label: {
Label(
provider.rawValue.capitalized,
systemImage: iconForProvider(provider.rawValue)
)
}
} label: {
Label("Link Account", systemImage: "plus")
}
} label: {
Label("Link Account", systemImage: "plus")
}
}
}
#endif
}
}

private func iconForProvider(_ provider: String) -> String {
Expand Down
2 changes: 1 addition & 1 deletion Examples/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Features:

## Prerequisites

- Xcode 15.0 or later
- Xcode 16.0 or later
- iOS 17.0+ / macOS 14.0+ or later
- [Supabase CLI](https://supabase.com/docs/guides/cli) installed

Expand Down
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.10
// swift-tools-version:6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import Foundation
Expand Down Expand Up @@ -204,7 +204,8 @@ let package = Package(
"Mocker",
]
),
]
],
swiftLanguageModes: [.v6]
)

for target in package.targets where !target.isTest {
Expand Down
2 changes: 1 addition & 1 deletion Package@swift-6.1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ let package = Package(
]
),
],
swiftLanguageModes: [.v5]
swiftLanguageModes: [.v6]
)

for target in package.targets where !target.isTest {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Supabase SDK for Swift. Mirrors the design of [supabase-js](https://github.com/s

### Requirements
- iOS 16.0+ / macOS 13+ / tvOS 16+ / watchOS 9+ / visionOS 1+
- Xcode 15.3+
- Swift 5.10+
- Xcode 16.0+
- Swift 6.0+

> [!IMPORTANT]
> Check the [Support Policy](#support-policy) to learn when dropping Xcode, Swift, and platform versions will not be considered a **breaking change**.
Expand Down
5 changes: 2 additions & 3 deletions Sources/Auth/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
private let globalJWKSCache = GlobalJWKSCache()

public actor AuthClient {
static var globalClientID = 0
static let globalClientID = LockIsolated(0)
nonisolated let clientID: AuthClientID

nonisolated private var api: APIClient { Dependencies[clientID].api }
Expand Down Expand Up @@ -122,8 +122,7 @@
/// - Parameters:
/// - configuration: The client configuration.
public init(configuration: Configuration) {
AuthClient.globalClientID += 1
clientID = AuthClient.globalClientID
clientID = AuthClient.globalClientID.withValue { $0 += 1; return $0 }

Dependencies[clientID] = Dependencies(
configuration: configuration,
Expand Down Expand Up @@ -367,7 +366,7 @@
method: .post,
query: [URLQueryItem(name: "grant_type", value: "password")],
body: configuration.encoder.encode(
UserCredentials(

Check warning on line 369 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, MACOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 369 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, MACOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 369 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (IOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 369 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (MACOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 369 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, IOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 369 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (MACOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 369 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, IOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 369 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (IOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.
email: email,
password: password,
gotrueMetaSecurity: captchaToken.map(AuthMetaSecurity.init(captchaToken:))
Expand All @@ -394,7 +393,7 @@
method: .post,
query: [URLQueryItem(name: "grant_type", value: "password")],
body: configuration.encoder.encode(
UserCredentials(

Check warning on line 396 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, MACOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 396 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, MACOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 396 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (IOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 396 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (MACOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 396 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, IOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 396 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (MACOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 396 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, IOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 396 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (IOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.
password: password,
phone: phone,
gotrueMetaSecurity: captchaToken.map(AuthMetaSecurity.init(captchaToken:))
Expand Down
44 changes: 13 additions & 31 deletions Sources/Storage/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,21 @@ import Foundation
import UniformTypeIdentifiers

func mimeType(forPathExtension pathExtension: String) -> String {
#if swift(>=5.9)
if #available(iOS 14, macOS 11, tvOS 14, watchOS 7, visionOS 1, *) {
return UTType(filenameExtension: pathExtension)?.preferredMIMEType
?? "application/octet-stream"
} else {
if let id = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, pathExtension as CFString, nil
)?.takeRetainedValue(),
let contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?
.takeRetainedValue()
{
return contentType as String
}

return "application/octet-stream"
if #available(iOS 14, macOS 11, tvOS 14, watchOS 7, visionOS 1, *) {
return UTType(filenameExtension: pathExtension)?.preferredMIMEType
?? "application/octet-stream"
} else {
if let id = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, pathExtension as CFString, nil
)?.takeRetainedValue(),
let contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?
.takeRetainedValue()
{
return contentType as String
}
#else
if #available(iOS 14, macOS 11, tvOS 14, watchOS 7, *) {
return UTType(filenameExtension: pathExtension)?.preferredMIMEType
?? "application/octet-stream"
} else {
if let id = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, pathExtension as CFString, nil
)?.takeRetainedValue(),
let contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?
.takeRetainedValue()
{
return contentType as String
}

return "application/octet-stream"
}
#endif
return "application/octet-stream"
}
}
#else

Expand Down
46 changes: 14 additions & 32 deletions Sources/Storage/MultipartFormData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -569,39 +569,21 @@ class MultipartFormData {
// MARK: - Private - Mime Type

static func mimeType(forPathExtension pathExtension: String) -> String {
#if swift(>=5.9)
if #available(iOS 14, macOS 11, tvOS 14, watchOS 7, visionOS 1, *) {
return UTType(filenameExtension: pathExtension)?.preferredMIMEType
?? "application/octet-stream"
} else {
if let id = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, pathExtension as CFString, nil
)?.takeRetainedValue(),
let contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?
.takeRetainedValue()
{
return contentType as String
}

return "application/octet-stream"
}
#else
if #available(iOS 14, macOS 11, tvOS 14, watchOS 7, *) {
return UTType(filenameExtension: pathExtension)?.preferredMIMEType
?? "application/octet-stream"
} else {
if let id = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, pathExtension as CFString, nil
)?.takeRetainedValue(),
let contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?
.takeRetainedValue()
{
return contentType as String
}

return "application/octet-stream"
if #available(iOS 14, macOS 11, tvOS 14, watchOS 7, visionOS 1, *) {
return UTType(filenameExtension: pathExtension)?.preferredMIMEType
?? "application/octet-stream"
} else {
if let id = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, pathExtension as CFString, nil
)?.takeRetainedValue(),
let contentType = UTTypeCopyPreferredTagWithClass(id, kUTTagClassMIMEType)?
.takeRetainedValue()
{
return contentType as String
}
#endif

return "application/octet-stream"
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/AuthTests/AuthClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ final class AuthClientTests: XCTestCase {
let validSession = Session.validSession
Dependencies[sut.clientID].sessionStorage.store(validSession)

let eventsTask = Task {
let eventsTask = Task { [sut] in
await sut.authStateChanges.prefix(2).collect()
}

Expand Down Expand Up @@ -236,7 +236,7 @@ final class AuthClientTests: XCTestCase {
let validSession = Session.validSession
Dependencies[sut.clientID].sessionStorage.store(validSession)

let eventsTask = Task {
let eventsTask = Task { [sut] in
await sut.authStateChanges.prefix(2).collect()
}

Expand Down Expand Up @@ -282,7 +282,7 @@ final class AuthClientTests: XCTestCase {
let validSession = Session.validSession
Dependencies[sut.clientID].sessionStorage.store(validSession)

let eventsTask = Task {
let eventsTask = Task { [sut] in
await sut.authStateChanges.prefix(2).collect()
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/AuthTests/MockHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension Decodable {
}

extension Dependencies {
static var mock = Dependencies(
static let mock = Dependencies(
configuration: AuthClient.Configuration(
url: URL(string: "https://project-id.supabase.com")!,
localStorage: InMemoryLocalStorage(),
Expand Down
2 changes: 1 addition & 1 deletion Tests/AuthTests/RequestsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ final class RequestsTests: XCTestCase {
record: Bool = false,
flowType: AuthFlowType = .implicit,
fetch: AuthClient.FetchHandler? = nil,
file: StaticString = #file,
file: StaticString = #filePath,
testName: String = #function,
line: UInt = #line
) -> AuthClient {
Expand Down
8 changes: 4 additions & 4 deletions Tests/AuthTests/SessionManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ final class SessionManagerTests: XCTestCase {

// Fire N tasks and call sut.session()
let tasks = (0..<10).map { _ in
Task { [weak self] in
try await self?.sut.session()
Task { [sut] in
try await sut.session()
}
}

Expand All @@ -104,7 +104,7 @@ final class SessionManagerTests: XCTestCase {
refreshSessionContinuation.finish()

// Await for all tasks to complete.
var result: [Result<Session?, Error>] = []
var result: [Result<Session, Error>] = []
for task in tasks {
let value = await task.result
result.append(value)
Expand All @@ -113,7 +113,7 @@ final class SessionManagerTests: XCTestCase {
// Verify that refresher and storage was called only once.
expectNoDifference(refreshSessionCallCount.value, 1)
expectNoDifference(
try result.map { try $0.get()?.accessToken },
try result.map { try $0.get().accessToken },
(0..<10).map { _ in validSession.accessToken }
)
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/FunctionsTests/FunctionsClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ final class FunctionsClientTests: XCTestCase {
"apikey": apiKey
],
region: region.flatMap(FunctionRegion.init(rawValue:)),
fetch: { request in
try await self.session.data(for: request)
fetch: { [session] request in
try await session.data(for: request)
},
sessionConfiguration: sessionConfiguration
)
Expand Down
2 changes: 1 addition & 1 deletion Tests/FunctionsTests/RequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class RequestTests: XCTestCase {
func snapshot(
record: Bool = false,
_ test: (FunctionsClient) async throws -> Void,
file: StaticString = #file,
file: StaticString = #filePath,
testName: String = #function,
line: UInt = #line
) async {
Expand Down
2 changes: 1 addition & 1 deletion Tests/PostgRESTTests/BuildURLRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class BuildURLRequestTests: XCTestCase {
init(
name: String,
record: Bool = false,
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line,
build: @escaping @Sendable (PostgrestClient) async throws -> PostgrestBuilder
) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/PostgRESTTests/PostgresQueryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class PostgrestQueryTests: XCTestCase {
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"
],
logger: nil,
fetch: {
try await self.session.data(for: $0)
fetch: { [session] in
try await session.data(for: $0)
},
encoder: {
let encoder = PostgrestClient.Configuration.jsonEncoder
Expand Down
Loading
Loading