For AI agents: the documentation index is at llms.txt. Guide pages have a markdown version at the same path with .md appended, before any query string or fragment.
Upgrade your app from supabase-swift v2 to v3 and fix the compile errors that the upgrade causes. v3 renames many public types and methods, so most errors come from a rename. This page covers the changes that affect every app.
For the full list, including the changes that still compile but behave differently, see the supabase-swift repository on GitHub. It has the v3 migration guide and the module guides for Auth, PostgREST, Storage, Functions, and Realtime.
3.0.0-alpha.2..package(url: "https://github.com/supabase/supabase-swift", from: "3.0.0-alpha.2")
v3 renames SupabaseClientOptions to SupabaseClient.Configuration, and the initializer label is configuration:. The nested types drop their Options suffix, and db is renamed to database.
In v3, every client initializer throws when the URL has no scheme or no host. Add try.
Headers are HTTPFields. Write each key as an HTTPField.Name.
let client = SupabaseClient(
supabaseURL: url,
supabaseKey: key,
options: SupabaseClientOptions(
db: .init(schema: "app"),
global: .init(headers: ["x-app": "demo"])
)
)
var configuration = SupabaseClient.Configuration()
configuration.database.schema = "app"
configuration.global.headers = [HTTPField.Name("x-app")!: "demo"]
let client = try SupabaseClient(
supabaseURL: url,
supabaseKey: key,
configuration: configuration
)
In v3, every logger: parameter takes a Logging.Logger from the swift-log package on GitHub. v3 removes SupabaseLogger and OSLogSupabaseLogger. Add swift-log to your package and import Logging where you build the logger.
When you pass no logger, debug builds log warnings and errors to stderr. Release builds stay silent.
import Logging
import Supabase
var logger = Logger(label: "myapp")
logger.logLevel = .debug
let client = try SupabaseClient(
supabaseURL: url,
supabaseKey: key,
configuration: .init(global: .init(logger: logger))
)
fetch closures and URLSession optionsv3 replaces the fetch closures and the URLSession options with a transport and middleware. Every client sends requests through one ClientTransport behind an ordered list of ClientMiddleware. Both go in one HTTPClientConfiguration, passed as http:. URLSessionTransport(session:) wraps the URLSession that you used in v2.
In v3, the SDK sets the request timeout itself: 60 seconds, or 150 seconds for Functions. To change it, set HTTPClientConfiguration(timeout:).
let client = SupabaseClient(
supabaseURL: url,
supabaseKey: key,
options: .init(global: .init(session: mySession))
)
let client = try SupabaseClient(
supabaseURL: url,
supabaseKey: key,
configuration: .init(
global: .init(http: .init(transport: URLSessionTransport(session: mySession)))
)
)
v3 removes HTTPError. Each module throws its own error type: AuthError, PostgrestError, StorageError, FunctionsError, or RealtimeError. Each one conforms to SupabaseError and has a kind, a code, the response, and an underlyingError.
The SDK wraps a URLError or DecodingError in the module error and keeps the original in underlyingError. In v3, a canceled task throws CancellationError in every module.
Errors that your own transport or middleware throws reach you unchanged. Keep the handlers for those errors.
do {
try await supabase.from("todos").insert(todo).execute()
} catch PostgrestError.Code.uniqueViolation {
showDuplicate()
} catch PostgrestError.Kind.transport {
showOfflineBanner()
} catch let error as any SupabaseError {
if let response = error.response {
print(response.status.code, String(decoding: response.body, as: UTF8.self))
}
}
v3 also renames the following methods, types, and arguments:
AnyJSON is renamed to JSONValue. Numbers are one case, .number(JSONNumber), which keeps every digit.supabase.realtimeV2 is renamed to supabase.realtime, and supabase.channel(_:) is async.supabase.handle(_:) is renamed to supabase.handleRedirect(_:).get prefix. For example, getPublicURL is publicURL.id:, and acronyms keep their capitals, as in factorID.v3 removes the following:
supabase.database. Use supabase.from(_:), supabase.rpc(_:), and supabase.schema(_:).