An iOS app backend has four jobs: sign users in, store their data with per-user rules, keep files, and push live updates. You can get all four from a backend-as-a-service instead of running servers. Firebase is the default for offline-first apps, Supabase is the best-known Postgres option, and WoWSQL gives you managed Postgres, auth, storage and realtime with a Swift package (WoWSQL-swift 3.10.0) on flat plans of $0, $25 and $99 a month.
This guide compares the main options for Swift developers, then builds a small SwiftUI app on WoWSQL: email sign-in with optional two-factor, a per-user todos table protected by Row Level Security, live refresh over WebSockets, and Sign in with Apple or Google through the web OAuth flow. Competitor facts were checked on each vendor's site on 24 November 2026.
Key facts
- WoWSQL Swift SDK: Swift Package Manager,
https://github.com/WoWSQL/WoWSQL-swiftfrom3.10.0, iOS 13+ and macOS 10.15+. It includesProjectAuthClient,WOWSQLClient(REST and realtime) andWOWSQLStorage(Swift SDK docs).- Auth (docs): email and password, magic links, email or phone OTP, OAuth with 19 working providers (Apple and Google among them), TOTP two-factor, optional Cloudflare Turnstile, and anonymous sign-in when enabled (not wrapped in the Swift SDK 3.10.0).
- Data API: auto-generated PostgREST API at
https://<project>.wowsqlconnect.com/rest/v1/. The anon key goes inapikey, and the signed-in user's JWT inAuthorization: Bearerso RLS applies. Never ship the service key in an app. No GraphQL API.- Plans (pricing, USD): Free $0 (1 project, 256 MB database, 512 MB files, 10,000 MAU, read-only when over a limit), Pro $25/month (dedicated Postgres, 10 GB database, 100 GB files, 100,000 MAU, daily backups kept 7 days), Scale $99/month (2,000,000 MAU, custom domains). Extra MAU cost $0.00325 each.
- Regions: Mumbai (
ap-south-1), US East (us-east-1) and Frankfurt (eu-central-1).
What an iOS app needs from a backend
- Sign-in that passes App Review. Under App Review Guideline 4.8, if you offer a third-party login such as Google for the user's primary account, you must also offer an equivalent privacy-focused login option. Sign in with Apple is the usual answer. Guideline 5.1.1(v) says that an app that supports account creation "must also offer account deletion within the app" (App Review Guidelines, last updated 16 October 2026).
- Per-user data rules enforced on the server. Anything in the app binary can be extracted, so the rules must live in the backend: Firestore security rules, or Postgres Row Level Security.
- Session handling. Store tokens in the Keychain, refresh them before they expire, and restore the session on launch.
- Live updates and files. Chat, feeds and shared lists need change events, and most apps need avatars or uploads.
- Offline behaviour. Decide early whether the app must work offline. It changes which backend fits best.
iOS backend options compared (24 November 2026)
| Data model | Swift SDK (latest release) | Native Sign in with Apple | Offline | Free tier | |
|---|---|---|---|---|---|
| Firebase | Firestore documents or Realtime Database JSON | firebase-ios-sdk 13.2.0 (13 Nov 2026) |
Yes | Built in; on by default on Apple platforms | Auth (with Identity Platform) free up to 50K MAU; Firestore 1 GiB, 50K reads and 20K writes a day |
| Supabase | Postgres + PostgREST + GraphQL | supabase-swift 2.55.7 (16 Nov 2026) |
Yes (signInWithIdToken) |
Not built in | 50,000 MAU, 500 MB database, paused after 1 week of inactivity |
| Appwrite | Appwrite databases | sdk-for-apple 21.3.0 (16 Nov 2026) |
OAuth with Apple | Not built in | See Appwrite pricing |
| CloudKit | Apple's iCloud records | Apple frameworks | Uses the user's iCloud account | Syncs across Apple devices | Set by Apple |
| WoWSQL | Postgres + PostgREST | WoWSQL-swift 3.10.0 |
Web OAuth flow (apple provider) |
Not built in | 10,000 MAU, 256 MB database, 512 MB files |
Sources: Firebase pricing, Firestore offline persistence, Firebase Sign in with Apple, firebase-ios-sdk releases; Supabase pricing, Supabase Sign in with Apple, supabase-swift releases; Appwrite pricing, Appwrite OAuth with Apple, sdk-for-apple releases; CloudKit; Supabase's guide to mobile backend providers; WoWSQL Swift SDK and pricing.
How to read it:
- Choose Firebase if the app must work offline and sync later. Its Apple SDK has the most mature local cache.
- Choose Supabase if you want Postgres with a much larger Swift community, native Sign in with Apple through an ID token, and a bigger free MAU allowance.
- Choose CloudKit for an Apple-only app that keeps data in the user's iCloud and doesn't need its own user accounts or an Android version.
- Choose Appwrite if self-hosting an open-source backend matters most to you.
- Choose WoWSQL if you want Postgres, auth, storage and realtime on flat plans, a choice of Mumbai, US East or Frankfurt, and an open-source edition (github.com/WoWSQL/WoWSQL, Apache-2.0) you can self-host later.
Build a SwiftUI todo app on WoWSQL
The app below signs users in, lists and edits their own todos, and refreshes when rows change. It targets iOS 16+ because it uses NavigationStack; the SDK itself supports iOS 13+.
Step 1: Create the project, table and policies
Create a free project at app.wowsql.com/signup in the region closest to your users, enable auth, and run this in the SQL editor:
create table public.todos (
id uuid primary key default gen_random_uuid(),
user_id uuid not null,
title text not null,
done boolean not null default false,
created_at timestamptz not null default now()
);
alter table public.todos enable row level security;
create policy "read own todos" on public.todos for select using (auth.uid() = user_id);
create policy "insert own todos" on public.todos for insert with check (auth.uid() = user_id);
create policy "update own todos" on public.todos for update using (auth.uid() = user_id) with check (auth.uid() = user_id);
create policy "delete own todos" on public.todos for delete using (auth.uid() = user_id);
Copy the anon key (wowsql_anon_…) from Settings → API. Enable realtime for the table once, from your terminal rather than the app, because it needs the service key:
curl -X POST "https://myproject.wowsqlconnect.com/realtime/v1/enable" \
-H "apikey: $WOWSQL_SERVICE_KEY" \
-H "Content-Type: application/json" \
-d '{"schema_name":"public","table_name":"todos"}'
Step 2: Add the Swift package
In Xcode, choose File → Add Package Dependencies, paste https://github.com/WoWSQL/WoWSQL-swift, pick version 3.10.0 or later, and add the WOWSQL library to your app target. In a Package.swift file the dependency is:
.package(url: "https://github.com/WoWSQL/WoWSQL-swift.git", from: "3.10.0")
Step 3: Keep tokens in the Keychain
ProjectAuthClient keeps tokens in memory unless you pass a TokenStorage. This small Keychain implementation keeps users signed in across app launches:
import Foundation
import Security
import WOWSQL
final class KeychainTokenStorage: TokenStorage {
private let service = "com.example.todos.wowsql"
func getAccessToken() -> String? { read("access_token") }
func setAccessToken(_ token: String?) { write("access_token", token) }
func getRefreshToken() -> String? { read("refresh_token") }
func setRefreshToken(_ token: String?) { write("refresh_token", token) }
private func baseQuery(_ key: String) -> [String: Any] {
[kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: service,
kSecAttrAccount as String: key]
}
private func read(_ key: String) -> String? {
var query = baseQuery(key)
query[kSecReturnData as String] = true
query[kSecMatchLimit as String] = kSecMatchLimitOne
var item: CFTypeRef?
guard SecItemCopyMatching(query as CFDictionary, &item) == errSecSuccess,
let data = item as? Data else { return nil }
return String(data: data, encoding: .utf8)
}
private func write(_ key: String, _ value: String?) {
SecItemDelete(baseQuery(key) as CFDictionary)
guard let value else { return }
var query = baseQuery(key)
query[kSecValueData as String] = Data(value.utf8)
query[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlock
SecItemAdd(query as CFDictionary, nil)
}
}
Step 4: The backend layer
Backend.swift creates the clients and a small REST helper. Why not client.table("todos")? In SDK 3.10.0, WOWSQLClient sends the API key you give it as the bearer token, so its queries run as the anon role. Per-user rows need the user's JWT in Authorization, so the helper calls the REST endpoints shown in the Swift SDK docs with both headers. It also refreshes the token once on a 401.
import Foundation
import WOWSQL
enum WoWSQLConfig {
static let projectURL = "https://myproject.wowsqlconnect.com"
static let anonKey = "wowsql_anon_your_key_here" // safe in the app; RLS decides access
}
// One auth client for the app. Tokens survive restarts via the Keychain.
let auth = ProjectAuthClient(
projectUrl: WoWSQLConfig.projectURL,
apiKey: WoWSQLConfig.anonKey,
tokenStorage: KeychainTokenStorage()
)
// Anon-key client, used here only for realtime change events.
let wowsql = WOWSQLClient(projectUrl: WoWSQLConfig.projectURL, apiKey: WoWSQLConfig.anonKey)
struct Todo: Codable, Identifiable {
let id: UUID
let userId: UUID
var title: String
var done: Bool
enum CodingKeys: String, CodingKey {
case id, title, done
case userId = "user_id"
}
}
enum APIError: Error {
case notSignedIn
case http(Int, String)
}
/// Calls the auto-generated REST API as the signed-in user, so RLS applies.
func rest(_ path: String, method: String = "GET", body: Data? = nil, retried: Bool = false) async throws -> Data {
guard let stored = auth.getSession()["access_token"], let token = stored else {
throw APIError.notSignedIn
}
var request = URLRequest(url: URL(string: "\(WoWSQLConfig.projectURL)/rest/v1/\(path)")!)
request.httpMethod = method
request.httpBody = body
request.setValue(WoWSQLConfig.anonKey, forHTTPHeaderField: "apikey")
request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("return=representation", forHTTPHeaderField: "Prefer")
let (data, response) = try await URLSession.shared.data(for: request)
let status = (response as? HTTPURLResponse)?.statusCode ?? 0
if status == 401 && !retried {
_ = try await auth.refreshToken() // POST /auth/v1/refresh-token, stores the new pair
return try await rest(path, method: method, body: body, retried: true)
}
guard (200..<300).contains(status) else {
throw APIError.http(status, String(decoding: data, as: UTF8.self))
}
return data
}
enum TodoAPI {
static func list() async throws -> [Todo] {
let data = try await rest("todos?select=id,user_id,title,done&order=created_at.desc")
return try JSONDecoder().decode([Todo].self, from: data)
}
static func add(_ title: String) async throws -> Todo {
let me = try await auth.getUser() // GET /auth/v1/me
let body = try JSONSerialization.data(withJSONObject: ["user_id": me.id, "title": title])
let data = try await rest("todos", method: "POST", body: body)
return try JSONDecoder().decode([Todo].self, from: data)[0]
}
static func setDone(_ todo: Todo, _ done: Bool) async throws {
let body = try JSONSerialization.data(withJSONObject: ["done": done])
_ = try await rest("todos?id=eq.\(todo.id.uuidString.lowercased())", method: "PATCH", body: body)
}
static func delete(_ todo: Todo) async throws {
_ = try await rest("todos?id=eq.\(todo.id.uuidString.lowercased())", method: "DELETE")
}
}
The WITH CHECK policy rejects an insert whose user_id isn't the caller's, so a tampered client can't write rows for someone else.
Step 5: Session state with two-factor support
import SwiftUI
import WOWSQL
@MainActor
final class SessionStore: ObservableObject {
@Published var isSignedIn = auth.getSession()["access_token"].flatMap { $0 } != nil
@Published var pendingTwoFactorToken: String?
@Published var message: String?
func signIn(email: String, password: String) async {
do {
let result = try await auth.signIn(email: email, password: password)
if result.requires2FA {
pendingTwoFactorToken = result.pendingToken // ask for the 6-digit code
} else {
isSignedIn = true
}
} catch {
message = error.localizedDescription
}
}
func verifyTwoFactor(code: String) async {
guard let pending = pendingTwoFactorToken else { return }
do {
_ = try await auth.verifyTwoFactorLogin(pendingToken: pending, code: code)
pendingTwoFactorToken = nil
isSignedIn = true
} catch {
message = error.localizedDescription
}
}
func signUp(email: String, password: String) async {
do {
let result = try await auth.signUp(email: email, password: password)
isSignedIn = result.session != nil
} catch {
message = error.localizedDescription
}
}
func signOut() async {
_ = try? await auth.logout() // POST /auth/v1/logout
auth.clearSession()
isSignedIn = false
}
}
If your project requires email verification, sign-up may not return a session. Show a "check your inbox" message and let the user sign in after verifying.
Step 6: The SwiftUI screens
import SwiftUI
@main
struct TodosApp: App {
@StateObject private var session = SessionStore()
var body: some Scene {
WindowGroup {
Group {
if session.isSignedIn { TodoListView() } else { LoginView() }
}
.environmentObject(session)
}
}
}
struct LoginView: View {
@EnvironmentObject var session: SessionStore
@State private var email = ""
@State private var password = ""
@State private var code = ""
var body: some View {
Form {
if session.pendingTwoFactorToken == nil {
TextField("Email", text: $email)
.textContentType(.username)
.keyboardType(.emailAddress)
.textInputAutocapitalization(.never)
SecureField("Password", text: $password)
.textContentType(.password)
Button("Sign in") { Task { await session.signIn(email: email, password: password) } }
Button("Create account") { Task { await session.signUp(email: email, password: password) } }
} else {
TextField("6-digit code", text: $code)
.keyboardType(.numberPad)
.textContentType(.oneTimeCode)
Button("Verify") { Task { await session.verifyTwoFactor(code: code) } }
}
if let message = session.message {
Text(message).foregroundStyle(.red)
}
}
}
}
struct TodoListView: View {
@EnvironmentObject var session: SessionStore
@State private var todos: [Todo] = []
@State private var newTitle = ""
@State private var stopRealtime: (() -> Void)?
var body: some View {
NavigationStack {
List {
HStack {
TextField("New todo", text: $newTitle)
Button("Add") { Task { await add() } }
.disabled(newTitle.isEmpty)
}
ForEach(todos) { todo in
Button {
Task { await toggle(todo) }
} label: {
Label(todo.title, systemImage: todo.done ? "checkmark.circle.fill" : "circle")
}
}
.onDelete { offsets in
let doomed = offsets.map { todos[$0] }
Task {
for todo in doomed { try? await TodoAPI.delete(todo) }
await load()
}
}
}
.navigationTitle("My todos")
.toolbar {
Button("Sign out") { Task { await session.signOut() } }
}
.refreshable { await load() }
.task {
await load()
startRealtime()
}
.onDisappear {
stopRealtime?()
stopRealtime = nil
}
}
}
private func load() async {
do { todos = try await TodoAPI.list() } catch { session.message = "\(error)" }
}
private func add() async {
let title = newTitle
newTitle = ""
_ = try? await TodoAPI.add(title)
await load()
}
private func toggle(_ todo: Todo) async {
try? await TodoAPI.setDone(todo, !todo.done)
await load()
}
// Treat change events as a "something changed" signal, then re-read through RLS.
private func startRealtime() {
guard stopRealtime == nil else { return }
stopRealtime = wowsql.realtime.subscribe(table: "todos") { _ in
Task { @MainActor in await load() }
}
}
}
The realtime socket authenticates with the anon key in the URL (wss://<project>.wowsqlconnect.com/realtime/v1/websocket?apikey=…). That is why the app only uses events as a signal to re-fetch through the REST API, where RLS applies. Before you enable realtime on a table with sensitive columns, check what an anon-key client actually receives. Payloads are capped at 64 KiB (realtime docs).
Step 7: Sign in with Apple or Google (web OAuth flow)
WoWSQL handles OAuth on its own callback URL, then redirects to your landing URL with access_token and refresh_token in the query string (OAuth for Projects). On iOS, open the authorization URL in ASWebAuthenticationSession and read the tokens from the final redirect:
import AuthenticationServices
import UIKit
import WOWSQL
@available(iOS 17.4, *) // for the .https callback
@MainActor
final class OAuthSignIn: NSObject, ASWebAuthenticationPresentationContextProviding {
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
UIApplication.shared.connectedScenes
.compactMap { ($0 as? UIWindowScene)?.keyWindow }
.first ?? ASPresentationAnchor()
}
/// provider: "apple", "google", "github", ...
func signIn(provider: String) async throws {
let start = try await auth.getOAuthAuthorizationUrl(
provider: provider,
redirectUri: "https://yourapp.com/auth/callback"
)
guard let url = URL(string: start["authorization_url"] ?? "") else { return }
let callbackURL: URL = try await withCheckedThrowingContinuation { continuation in
let session = ASWebAuthenticationSession(
url: url,
callback: .https(host: "yourapp.com", path: "/auth/callback")
) { url, error in
if let url { continuation.resume(returning: url) }
else { continuation.resume(throwing: error ?? URLError(.cancelled)) }
}
session.presentationContextProvider = self
session.start()
}
let items = URLComponents(url: callbackURL, resolvingAgainstBaseURL: false)?.queryItems ?? []
guard let access = items.first(where: { $0.name == "access_token" })?.value else {
throw URLError(.userAuthenticationRequired)
}
auth.setSession(accessToken: access,
refreshToken: items.first(where: { $0.name == "refresh_token" })?.value)
}
}
Notes before you ship this:
- Configure each provider under Project → Auth → Providers and register
https://<slug>.wowsqlconnect.com/auth/v1/oauth/<provider>/callbackin the provider's console. For Apple, the client secret is the signed JWT that Apple requires, and it expires after at most six months, so put a renewal on your calendar. - The
.httpscallback needs iOS 17.4+ and an associated domain foryourapp.com. The WoWSQL docs show https landing URLs; if you want a custom URL scheme instead, test that your project accepts it. - This is the web flow, not the native Apple button. WoWSQL's docs don't describe exchanging a native Sign in with Apple ID token, which Supabase supports with
signInWithIdToken. If the native sheet matters to you, that is a point for Supabase.
Before you ship: a production checklist
- Keys: only the anon key goes in the app. Keep the service key in a server, CI secret or Edge Function (Pro and Scale).
- RLS on every table the app touches. Test with two real accounts that one can't read the other's rows.
- Account deletion (Guideline 5.1.1(v)). The WoWSQL auth docs and Swift SDK 3.10.0 don't list a self-service "delete my account" endpoint as of 24 November 2026. Delete the user's rows through the REST API and plan the auth-account removal with WoWSQL support or your own server process before you submit.
- Token lifetimes: access tokens last 24 hours by default and refresh tokens 30 days. The helper above refreshes on
401. - Two-factor: Swift 3.10.0 wraps TOTP setup (
setupTotp,enableTotp), sign-in verification and recovery codes. It does not wrap anonymous sign-in, identity linking or email change; the TypeScript, Python and Java SDKs do. - Region: pick the region nearest most users: US East for the Americas, Frankfurt for Europe and the UK (there is no UK region), Mumbai for India.
- Backups: Free has no platform backups, so export your own. Pro and Scale get daily backups kept 7 days (backups policy). This is not point-in-time recovery.
- Files:
WOWSQLStorageuploads, lists, downloads and deletes files in buckets, and returns public URLs for public buckets. See File Storage for Web and Mobile Apps for the trade-offs.
Where others are better than WoWSQL for iOS
- Offline sync: Firebase's Apple SDK caches data and syncs later by default. With WoWSQL you build caching yourself.
- Native Sign in with Apple: Supabase documents the native ID-token flow. WoWSQL documents the web OAuth flow.
- Free tier size: Supabase's free plan includes 50,000 MAU and a 500 MB database, against WoWSQL's 10,000 MAU and 256 MB. Supabase pauses free projects after a week of inactivity, though.
- Ecosystem: Firebase and Supabase have far more Swift samples and community answers.
- Swift SDK coverage: WoWSQL's Swift package wraps fewer auth features than its TypeScript SDK, and user-scoped queries need the small REST helper shown above.
WoWSQL's case: Postgres and SQL from day one, auth with TOTP and 19 OAuth providers, realtime and storage on every plan, flat pricing ($0, $25, $99), three regions, and an Apache-2.0 self-hosted edition if you ever want to run it yourself.
Related guides
- React Native Postgres Backend with the WoWSQL SDK
- Flutter Postgres Backend with the wowsql Dart SDK
- What Is PostgREST? Auto REST APIs for Postgres
- What Is Row Level Security in Postgres? With Examples
- WoWSQL vs Firebase: Postgres or Firestore for Your App?
- Best Backend for an MVP in 2026: Ship in a Weekend
- DPDP Act for Developers: A Backend Checklist
FAQ
What is the best backend for an iOS Swift app?
It depends on the app. Firebase is best for offline-first sync, Supabase for Postgres with native Sign in with Apple and a large Swift community, CloudKit for Apple-only apps that store data in the user's iCloud, and WoWSQL for Postgres, auth, storage and realtime with a Swift package on flat $0, $25 and $99 plans.
Is there a good Firebase alternative for iOS?
Yes. If you want SQL instead of documents, Supabase and WoWSQL both give you Postgres with Row Level Security, auth, storage and realtime, plus Swift SDKs. Firebase still has the most mature offline cache on Apple platforms, so choose it if offline sync is essential.
How do I connect a SwiftUI app to a Postgres database?
Don't connect directly from the app. Use a backend that exposes Postgres over HTTPS with per-user rules. With WoWSQL, add the WoWSQL-swift package, sign the user in with ProjectAuthClient, and call https:// Yes, through the web OAuth flow. apple is one of WoWSQL's OAuth providers: open the authorization URL in ASWebAuthenticationSession and read the access and refresh tokens from the redirect. WoWSQL's docs don't describe a native ID-token exchange, which Supabase offers. Yes. Pass a TokenStorage to ProjectAuthClient, for example a small Keychain-backed class. The client reads the stored tokens on launch, and refreshToken() calls POST /auth/v1/refresh-token when the access token expires (24 hours by default). Yes. client.realtime.subscribe(table:) receives INSERT, UPDATE and DELETE events from tables you enable with POST /realtime/v1/enable, and channels support broadcast and presence. The socket uses the anon key, so a safe pattern is to treat events as a signal and re-fetch through the REST API with the user's token. Free is $0 with 10,000 monthly active users and a 256 MB database. Pro is $25 a month with a dedicated Postgres instance, 100,000 MAU and daily backups kept 7 days. Scale is $99 a month with 2,000,000 MAU. Extra users cost $0.00325 each on paid plans. with the anon key in apikey and the user's JWT in Authorization, so Row Level Security filters the rows.
Does WoWSQL support Sign in with Apple?
Can I keep users signed in after the app restarts?
Does the WoWSQL Swift SDK support realtime?
How much does an iOS app backend cost on WoWSQL?