Recipe · checked November 18, 2026

Native iPhone app in Swift

An iPhone (and iPad) app written in Swift and SwiftUI with Xcode, for teams that ship on Apple platforms only. Xcode Cloud builds every push and delivers it to TestFlight, Supabase's Swift SDK is the backend behind row-level security, Sign in with Apple is the login, in-app purchase goes through RevenueCat (or StoreKit 2 directly) when the app charges, and notifications go straight to Apple's APNs.

Tool bills at 1,000 usersAbout $0/month
Setup steps9
Tools in the stack8

Fits when

  • The app ships on iPhone or iPad only, or Android can wait for a separate app later.
  • You or your team write Swift, or want the platform's own UI, widgets, Live Activities, HealthKit or other Apple frameworks without a bridge.
  • You have a Mac to write and debug the app in Xcode.

Not for

  • Apps that must launch on Android at the same time from one codebase: use the mobile-subscription-app recipe (React Native with Expo).
  • Web developers who don't know Swift and don't own a Mac: Expo builds iOS in the cloud from React.
  • Apps where users pay each other for real-world services: use the marketplace recipe for payments; this recipe's build, sign-in and store steps still apply.
  • Games built in a game engine: Cuely doesn't cover engines.

The stack

CategoryPickWhyPick something else when
Mobile buildsApple's build service: every push is built, tested, signed and sent to TestFlight, and 25 compute hours a month come with the $99 Apple Developer Program.
  • Xcode and Android Studio: One developer shipping now and then: archive and upload from Xcode on your Mac (Product > Archive) and skip CI.
  • Expo (EAS): You decide to ship Android from the same code: that means React Native, not Swift.
DatabasePostgres with an official Swift SDK the app calls directly, protected by row-level security tied to the signed-in user, plus storage and edge functions for anything that needs a secret.
  • Firebase: You want an offline-first document database with Google's Swift SDKs, and no SQL.
AuthTakes the identity token from the native Sign in with Apple sheet, so sign-in is one tap and row-level security uses the same user id.
  • Clerk: You want hosted user management and prebuilt screens, and don't mind a second vendor next to Supabase.
PaymentsWraps StoreKit with entitlements, receipt checks, paywalls and webhooks to your backend, free until $2,500 in monthly tracked revenue. StoreKit 2 alone also works for a simple app; you then build the server checks with the App Store Server API yourself.
  • Stripe: Only for purchases on your website, for example a US storefront link-out (App Review Guideline 3.1.1(a)). Never as checkout inside the app.
EmailoptionalSign-in codes and account notices from your own domain once Supabase's built-in sender is too limited.
  • Postmark: Transactional deliverability and long retention matter most.
Push notificationsoptionalAn iPhone-only app can send straight to Apple's APNs from an edge function with a token signing key: no push vendor, no SDK in the app, nothing to pay.
  • Firebase Cloud Messaging: An Android app will follow, or the backend is already Firebase: one API for both.
  • OneSignal: Non-developers will send marketing or re-engagement campaigns to segments of users.
MonitoringCrash reports with symbolicated Swift stack traces once dSYMs are uploaded from each build.
  • Better Stack: You also want uptime checks on your backend functions.
AnalyticsoptionalAn iOS SDK for product analytics and funnels, without cross-app tracking, so no tracking permission prompt is needed.—

About $0/month at 1,000 users in tool bills: $0 for Xcode Cloud, Supabase, Supabase Auth, RevenueCat, Sentry. Usage profile: 1,000 monthly active users with light use: about 100,000 requests, 3,000 emails, 200,000 analytics events and 5 GB of stored files a month, and a database under 1 GB. AI apps add 50 questions per user a month at about 4,000 input and 500 output tokens each (200M input and 25M output tokens). Internal tools are priced for 10 staff instead.

Catches that change the plan

Setup steps

  1. Enroll, then create the Xcode project

    Apple enrollment can take days, so start it first. Uploads must be built with a current Xcode, so install it before you write code.

    • Enroll in the Apple Developer Program ($99 a year). Organizations need a D-U-N-S number; individuals don't.
    • If you qualify (under $1M in App Store proceeds last calendar year, or new to the store), apply for the App Store Small Business Program for the 15% rate before your first sale.
    • Install Xcode 26 or later: since April 28, 2026, App Store Connect only accepts builds made with the iOS 26 SDK.
    • Create an iOS App project with SwiftUI, set the bundle identifier you'll keep forever (com.yourcompany.app), and pick a minimum iOS version no lower than iOS 13 (required since September 9, 2026).
    • Add Swift packages with File > Add Package Dependencies: supabase-swift, purchases-ios (RevenueCat) if the app charges, and sentry-cocoa.
    • Commit the project to git with a .gitignore for Xcode (xcuserdata, DerivedData).

    Done when: The app runs on a simulator and on your own iPhone from Xcode, signed with your team.

    Docs: developer.apple.com, developer.apple.com, developer.apple.com

  2. Create the backend with row-level security

    The app talks to Supabase directly with the publishable key, which anyone can read out of the app. Row-level security is what keeps one user's rows from another.

    • Create a Supabase project and enable row-level security on every table before the first TestFlight build.
    • Give every user-owned table a user_id referencing auth.users and a policy that checks auth.uid().
    • Keep anything that needs a secret (AI calls, admin actions, webhooks) in edge functions; only the URL and publishable key go in the app.
    • Create one SupabaseClient for the app and reuse it.
    npm i -g supabase
    supabase init
    supabase migration new init
    supabase/migrations/0001_init.sql
    create table notes (
      id uuid primary key default gen_random_uuid(),
      user_id uuid not null references auth.users(id) on delete cascade default auth.uid(),
      body text not null,
      created_at timestamptz not null default now()
    );
    create index on notes (user_id);
    
    -- Written only by the RevenueCat webhook (service role). The app reads it.
    create table entitlements (
      user_id uuid primary key references auth.users(id) on delete cascade,
      entitlement text not null,
      active boolean not null,
      expires_at timestamptz,
      updated_at timestamptz not null default now()
    );
    
    alter table notes enable row level security;
    alter table entitlements enable row level security;
    
    create policy "own notes" on notes for all using (auth.uid() = user_id) with check (auth.uid() = user_id);
    create policy "read own entitlement" on entitlements for select using (auth.uid() = user_id);
    
    -- Optional: APNs device tokens, one row per device. sandbox is true for builds run from Xcode.
    create table push_tokens (
      token text primary key,
      user_id uuid not null references auth.users(id) on delete cascade default auth.uid(),
      sandbox boolean not null default false,
      created_at timestamptz not null default now()
    );
    alter table push_tokens enable row level security;
    create policy "own push tokens" on push_tokens for all using (auth.uid() = user_id) with check (auth.uid() = user_id);
    
    -- The APNs provider token, reused for 20 to 60 minutes as Apple requires. Server only: no policies.
    create table apns_token (id int primary key, jwt text not null, issued_at timestamptz not null);
    alter table apns_token enable row level security;
    
    App/Backend.swift
    import Foundation
    import Supabase
    
    // The URL and publishable key are public; never put the service role key in the app.
    let supabase = SupabaseClient(
      supabaseURL: URL(string: "https://YOUR-PROJECT.supabase.co")!,
      supabaseKey: "YOUR-PUBLISHABLE-KEY"
    )
    
    struct Note: Codable, Identifiable {
      let id: UUID
      let body: String
    }
    
    func loadNotes() async throws -> [Note] {
      // Row-level security limits this to the signed-in user's rows.
      try await supabase.from("notes").select("id, body").order("created_at", ascending: false).execute().value
    }
    

    Done when: Signed in as one test user, the app can't read or write another test user's notes.

    Docs: supabase.com, supabase.com

  3. Add Sign in with Apple and account deletion

    Apple requires in-app account deletion when the app creates accounts (Guideline 5.1.1(v)), and an equivalent private login such as Sign in with Apple if you offer Google or another social login (4.8).

    • Add the Sign in with Apple capability in Xcode and turn on the Apple provider in Supabase with your bundle identifier.
    • Use the native SignInWithAppleButton and pass its identity token to Supabase; no web view.
    • Let people use the parts that don't need an account before signing in (Guideline 5.1.1(v)).
    • Add Delete Account in Settings: an edge function deletes the user's rows and the auth user with the service role key.
    • When the account used Sign in with Apple, revoke its tokens with Apple's REST API as part of deletion, as Apple's account deletion page asks.
    • Deleting the account doesn't cancel an App Store subscription: tell the user and link to their subscription settings.
    App/SignInView.swift
    import AuthenticationServices
    import Supabase
    import SwiftUI
    
    struct SignInView: View {
      var body: some View {
        SignInWithAppleButton(.signIn) { request in
          request.requestedScopes = [.email, .fullName]
        } onCompletion: { result in
          Task {
            guard case .success(let auth) = result,
                  let credential = auth.credential as? ASAuthorizationAppleIDCredential,
                  let tokenData = credential.identityToken,
                  let idToken = String(data: tokenData, encoding: .utf8) else { return }
            try await supabase.auth.signInWithIdToken(
              credentials: OpenIDConnectCredentials(provider: .apple, idToken: idToken)
            )
          }
        }
        .frame(height: 48)
      }
    }
    

    Done when: A test account signs in with Apple, deletes itself from Settings, can't sign in again, and its rows are gone.

    Docs: developer.apple.com, supabase.com, developer.apple.com

  4. Optional: sell a subscription with in-app purchase

    Digital features inside an iOS app must be sold with in-app purchase (Guideline 3.1.1). Skip this step if nothing in the app is paid.

    • Have the Account Holder accept the Paid Apps Agreement and add tax and banking details in App Store Connect; products don't load, even in sandbox, until it's active.
    • Create a subscription group and an auto-renewable subscription (for example pro_monthly); periods must be at least seven days (Guideline 3.1.2).
    • In RevenueCat, add the app with an App Store Connect API key, create the entitlement pro and an offering, then configure the SDK after sign-in with the Supabase user id as the app user id.
    • Or, for one simple subscription, use StoreKit 2 directly: Product.products(for:), product.purchase(), and Transaction.currentEntitlements; verify on your server with the App Store Server API.
    • Show the store's localized price, what the subscriber gets, the billing period, Restore Purchases, and links to your terms and privacy policy on the paywall.
    • Add a StoreKit configuration file in Xcode to test purchases, renewals and refunds locally before sandbox.
    App/Purchases.swift
    import RevenueCat
    
    // The public Apple SDK key from the RevenueCat dashboard (safe to ship in the app).
    func configurePurchases(userId: String) {
      Purchases.configure(withAPIKey: "appl_YOUR_PUBLIC_KEY", appUserID: userId)
    }
    
    func isPro() async -> Bool {
      let info = try? await Purchases.shared.customerInfo()
      return info?.entitlements["pro"]?.isActive == true
    }
    
    func restore() async -> Bool {
      let info = try? await Purchases.shared.restorePurchases()
      return info?.entitlements["pro"]?.isActive == true
    }
    

    Done when: In a StoreKit test session and then in sandbox, buying, restoring on a second device and expiring all change what the app unlocks.

    Docs: developer.apple.com, developer.apple.com, revenuecat.com, developer.apple.com

  5. Optional: mirror entitlements to the backend

    The app checks RevenueCat for the paywall, but anything the server does for paying users must check the entitlement your backend stored. Skip this step if nothing in the app is paid.

    • Point a RevenueCat webhook at a Supabase edge function with a long random Authorization header value.
    • Reject requests without it, skip event ids you've already stored, and upsert the user's entitlement and expiry.
    • Gate server features (sync limits, AI calls, exports) on the entitlements table, never on a flag the app sends.
    • The mobile-subscription-app recipe's webhook function works unchanged for a Swift app.

    Done when: A sandbox purchase sets the user's entitlement to active within a minute, and its expiry clears it.

    Docs: revenuecat.com

  6. Optional: send push notifications through APNs

    Your backend signs a short-lived token with an APNs key and sends each notification to Apple over HTTP/2. The permission prompt shows once, so ask when the user turns on something that needs it.

    • Add the Push Notifications capability in Xcode, and create an APNs authentication key (.p8) in Certificates, Identifiers & Profiles; store it, its key id and your team id as edge function secrets.
    • Ask with UNUserNotificationCenter when the user turns on reminders, call registerForRemoteNotifications, and store the device token in push_tokens (sandbox for builds run from Xcode; TestFlight and App Store builds use production).
    • Send from an edge function: an ES256 token signed with the key, reused for 20 to 60 minutes (Apple rejects tokens refreshed more often than every 20 minutes or older than an hour), POSTed to /3/device/<token> with apns-topic set to your bundle id.
    • Delete a token when APNs answers 410; it means the app was removed or the token expired.
    • Don't put private details in the notification text, don't make the app require notifications, and send marketing pushes only to people who opted in, with a way to opt out (Guideline 4.5.4).
    App/Push.swift
    import Supabase
    import SwiftUI
    import UserNotifications
    
    // In your App: @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    final class AppDelegate: NSObject, UIApplicationDelegate {
      func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let token = deviceToken.map { String(format: "%02x", $0) }.joined()
        #if DEBUG
        let sandbox = true // builds run from Xcode use the APNs development server
        #else
        let sandbox = false
        #endif
        struct Row: Encodable { let token: String; let sandbox: Bool }
        Task { try? await supabase.from("push_tokens").upsert(Row(token: token, sandbox: sandbox)).execute() }
      }
    }
    
    // Call when the user turns on reminders, not at first launch.
    func enablePush() async -> Bool {
      let granted = (try? await UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound])) ?? false
      if granted { await MainActor.run { UIApplication.shared.registerForRemoteNotifications() } }
      return granted
    }
    
    supabase/functions/send-push/apns.ts
    import { createClient } from "npm:@supabase/supabase-js@2";
    import { importPKCS8, SignJWT } from "npm:jose@5";
    
    const admin = createClient(Deno.env.get("SUPABASE_URL")!, Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!);
    const TEAM_ID = Deno.env.get("APNS_TEAM_ID")!;
    const KEY_ID = Deno.env.get("APNS_KEY_ID")!;
    const BUNDLE_ID = Deno.env.get("APNS_BUNDLE_ID")!;
    
    // APNs wants one token reused for 20 to 60 minutes, so it lives in the database between invocations.
    async function providerToken(): Promise<string> {
      const { data } = await admin.from("apns_token").select("jwt, issued_at").eq("id", 1).maybeSingle();
      if (data && Date.now() - new Date(data.issued_at).getTime() < 50 * 60_000) return data.jwt;
      const key = await importPKCS8(Deno.env.get("APNS_PRIVATE_KEY")!, "ES256");
      const jwt = await new SignJWT({ iss: TEAM_ID }).setProtectedHeader({ alg: "ES256", kid: KEY_ID }).setIssuedAt().sign(key);
      await admin.from("apns_token").upsert({ id: 1, jwt, issued_at: new Date().toISOString() });
      return jwt;
    }
    
    export async function sendToUser(userId: string, title: string, body: string) {
      const jwt = await providerToken();
      const { data: tokens } = await admin.from("push_tokens").select("token, sandbox").eq("user_id", userId);
      for (const t of tokens ?? []) {
        const host = t.sandbox ? "api.sandbox.push.apple.com" : "api.push.apple.com";
        const res = await fetch(`https://${host}/3/device/${t.token}`, { // Deno's fetch speaks HTTP/2, which APNs requires
          method: "POST",
          headers: { authorization: `bearer ${jwt}`, "apns-topic": BUNDLE_ID, "apns-push-type": "alert", "apns-priority": "10" },
          body: JSON.stringify({ aps: { alert: { title, body }, sound: "default" } }),
        });
        if (res.status === 410) await admin.from("push_tokens").delete().eq("token", t.token); // no longer active
      }
    }
    

    Done when: A TestFlight build that turned on reminders gets a notification sent from the edge function, and deleting the app makes the next send remove its token.

    Docs: developer.apple.com, developer.apple.com, developer.apple.com

  7. Write the privacy manifest and decide on tracking

    Since May 1, 2024, uploads need approved reasons for certain APIs, including ones called by third-party SDKs. Tracking across other companies' apps needs the user's permission (Guideline 5.1.2(i)).

    • Add a PrivacyInfo.xcprivacy file to the app target and declare an approved reason for each required-reason API the app calls (UserDefaults, file timestamps, disk space, system boot time).
    • List the data the app collects in it, and keep it in step with the App Store privacy details you'll fill in at submission.
    • Use SDK versions that ship their own privacy manifests; Xcode merges them into the privacy report (Product > Archive, then Generate Privacy Report).
    • If the app or an SDK links its data with other companies' data for advertising, ask with App Tracking Transparency first. Product analytics that stays with you isn't tracking, so most apps never show the prompt.
    • Don't require tracking, notifications or location to use the app (Guideline 5.1.2(i)).
    App/PrivacyInfo.xcprivacy
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>NSPrivacyTracking</key>
      <false/>
      <key>NSPrivacyTrackingDomains</key>
      <array/>
      <key>NSPrivacyCollectedDataTypes</key>
      <array/>
      <key>NSPrivacyAccessedAPITypes</key>
      <array>
        <dict>
          <key>NSPrivacyAccessedAPIType</key>
          <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
          <key>NSPrivacyAccessedAPITypeReasons</key>
          <array>
            <string>CA92.1</string>
          </array>
        </dict>
      </array>
    </dict>
    </plist>
    

    Done when: Xcode's privacy report for an archive lists every SDK, and an upload to App Store Connect raises no missing-reason warning.

    Docs: developer.apple.com, developer.apple.com

  8. Build with Xcode Cloud and test on TestFlight

    Each push to main becomes a signed build in TestFlight, so testers always have the latest version and nobody archives by hand.

    • Create the app record in App Store Connect with the same bundle identifier.
    • In Xcode, choose Product > Xcode Cloud > Create Workflow: start on pushes to main, archive for iOS, and add a post-action for TestFlight internal testing.
    • Add crash reporting: configure Sentry at launch and upload dSYMs from each build so stack traces are readable.
    • If the app only uses HTTPS and Apple's built-in encryption, set ITSAppUsesNonExemptEncryption to NO in Info.plist so builds don't stop at the export compliance question.
    • Invite up to 100 internal testers from your team; for up to 10,000 external testers, add a beta description and pass beta App Review first.

    Done when: A push to main shows up as a new build in TestFlight on a tester's phone, and a test crash appears in Sentry with Swift file names and lines.

    Docs: developer.apple.com, developer.apple.com, developer.apple.com, docs.sentry.io

  9. Submit to the App Store

    App Store Connect asks for several things beyond the build; missing ones block submission or get the app pulled in some regions.

    • Fill in the App Store privacy details from your privacy manifest and every SDK in the app.
    • Answer the age rating questions; the questionnaire changed with Apple's new rating system and was required for all apps by January 31, 2026.
    • Declare your EU Digital Services Act trader status. Traders must provide an address, phone number and email that Apple shows on the product page; apps without a status were removed from the EU App Store from February 17, 2025.
    • Give App Review a demo account, notes on where paid features are and how to test them, and a support URL.
    • Release with phased release on so an update reaches users over seven days and can be paused.

    Done when: The app is approved and live, and a fresh install from the App Store can sign in, use the app and (if paid) buy and restore.

    Docs: developer.apple.com, developer.apple.com, developer.apple.com

Best practices

  • Keep the app's only keys public ones (Supabase URL and publishable key, RevenueCat's Apple SDK key); everything secret runs in edge functions.
  • Turn on row-level security for every table before the first TestFlight build.
  • Use the backend user id as RevenueCat's app user id, so a subscription follows the account, not the phone.
  • Unlock paid features from the entitlement (RevenueCat or StoreKit's current entitlements), never from a value saved on the device.
  • Build every push in Xcode Cloud so the build you test is the build you ship.
  • Keep the privacy manifest, App Store privacy details and your privacy policy in step whenever you add an SDK.

Pitfalls

  • Uploading a build made with an old Xcode: since April 28, 2026, App Store Connect only accepts builds made with the iOS 26 SDK.
  • Selling digital features with Stripe or a web checkout inside the app: Apple rejects it (Guideline 3.1.1).
  • Offering Google sign-in without Sign in with Apple or another equivalent private login (Guideline 4.8).
  • Deleting the account in Supabase but not revoking the Sign in with Apple tokens.
  • Forgetting the Paid Apps Agreement, so products never load in sandbox.
  • Adding an analytics or ads SDK without updating the privacy manifest and privacy details.
  • Shipping the Supabase service role key or any other secret inside the app bundle.
  • Sending pushes to the production APNs server from a build run in Xcode (or the reverse): sandbox tokens only work on the development server.
  • Making a new APNs token for every send: Apple rejects tokens refreshed more often than every 20 minutes.

Costs and obligations

These point to obligations to check; they aren't legal or tax advice.