Architecture recap:
AuthProviding is the seam (in AcornCore). The default
AnonymousAuthProvider (guest, no backend) ships in core; SupabaseAuthProvider
ships in the optional AcornCoreSupabase module. The flow gate (AppFlowCoordinatorAcornGateView) and theAuthScreenUI are backend-agnostic.
Part A — Backend setup (one-time, ~30 min)
A1. Create a Supabase project
- supabase.com → New project. Note the Project URL (
https://<ref>.supabase.co) and the anon public key (Project Settings → API). - These are the only two values the app needs. The anon key is safe to ship in the client; never ship the service-role key.
A2. Enable email auth
Authentication → Providers → Email is on by default. Decide whether to require email confirmation (Authentication → Settings). If on,signUp returns no session until the user confirms — AuthScreen already handles this (shows “check your email”, flips to sign-in).
A3. Enable Sign in with Apple
Apple requires Sign in with Apple if you offer any social login (Guideline 4.8), and it’s the primary iOS method. In Xcode: Target → Signing & Capabilities → + Capability → Sign in with Apple. In the Apple Developer portal:- Identifiers → your App ID → enable “Sign in with Apple”.
- Create a Services ID (for the Supabase callback), enable Sign in with Apple, and set the return URL to
https://<ref>.supabase.co/auth/v1/callback. - Create a Sign in with Apple Key (.p8), note the Key ID and your Team ID.
For native iOS the app uses
ASAuthorizationAppleIDCredential directly (no web
redirect), but Supabase still needs the Apple provider configured to verify the
identity token server-side.A4. Deploy the delete-user Edge Function (account deletion)
Apple requires in-app account deletion (Guideline 5.1.1(v)). Supabase has no
client-side user delete, so SupabaseAuthProvider.deleteAccount() invokes an Edge
Function that runs with the service-role key.
supabase/functions/delete-user/index.ts
supabase functions deploy delete-user. (SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY are injected automatically for deployed functions.) The provider’s deleteUserFunction defaults to "delete-user"; override in the initializer if you name it differently.
Part B — App wiring (3 steps)
Add the dependency
The app already depends on
AcornCore. Add the AcornCoreSupabase product to the
app target (it pulls supabase-swift). Local-package apps just add the product;
SPM apps add https://github.com/supabase/supabase-swift.git transitively via the
module.Create the provider
AnonymousAuthProvider() — same protocol,
nothing else changes. Want RevenueCat entitlements tied to the account? Pass the
user id as appUserID to RevenueCatSubscriptionProvider after sign-in.Wiring account deletion to data reset (Settings)
deleteAccount() removes the auth user; pair it with DataResetting so the user’s
local + remote app data goes too:
delete-user Edge Function delete the user’s rows server-side — then
resetter only needs the local wipe.)
Pre-ship checklist
- Supabase URL + anon key in config (not the service-role key).
- Email confirmation decision made (on/off).
- Sign in with Apple: Xcode capability + App ID + Services ID + key + Supabase provider.
-
delete-userEdge Function deployed; account-deletion control wired in Settings. - Live test in simulator/device: sign up, sign in (email + Apple), reset password, sign out, delete account; confirm the gate advances
onboarding → auth → paywall → main. - Privacy: list “email”/“user id” in App Privacy; ensure Terms/Privacy links shown on
AuthScreen(passlegalLinks).