iOS host sample¶
A ready-to-run iOS host app for the shared sample:compose-passkey Compose UI.
Use this sample when you want to run the passkey demo on a connected iPhone from Xcode with minimal setup.
What is included¶
- A committed Xcode app project (
ComposePasskeyIos.xcodeproj). - SwiftUI app shell that mounts Kotlin
MainViewController()fromsample:compose-passkey. - Build phase script that runs
:sample:compose-passkey:embedAndSignAppleFrameworkForXcode.
Quick run on a device with a free Apple account¶
This path verifies the app is runnable on a real phone without a paid Apple Developer Program membership.
- Open Xcode project:
- In Xcode target settings (
ComposePasskeyIos): - Set a unique bundle ID (for example
dev.webauthn.samples.composepasskey.ios.<yourname>). - Set
Signing & Capabilitiesto your personal team. -
Keep automatic signing enabled.
-
Select your connected iPhone and run.
Expected result:
- App installs and launches.
- Compose UI renders with the Auth screen first (Register / Sign In).
- Signed-in debug logs remain hidden unless the title is double-tapped.
Note: - Passkey registration and sign-in may fail with a free account when the Associated Domains entitlement or domain association is unavailable.
Complete passkey path with Associated Domains¶
Use this path when your signing setup supports Associated Domains and you want successful registration and sign-in.
- Start backend with tunnel helper:
- Ensure app identity matches backend AASA config:
- Canonical value is
IOS_APP_ID. - If
IOS_APP_IDis unset, backend derives it fromIOS_TEAM_ID.IOS_BUNDLE_ID. -
IOS_APP_IDmust match your signed app ID (<TEAM_ID>.<BUNDLE_ID>). -
In Xcode, add capability:
Signing & Capabilities->Associated Domains-
Add
webcredentials:<your-https-domain>(the ngrok host from helper output). -
Rebuild and run the iOS app.
Expected result:
- Register completes.
- Sign In completes.
- Signed-in extension demo screen is shown after successful sign-in.
- PasskeyDemo logs appear in Xcode console and in the hidden in-app debug sheet (title double-tap).
Environment variables used by the shared sample¶
Build-time values come from Gradle properties / env vars / local.properties:
WEBAUTHN_DEMO_ENDPOINTWEBAUTHN_DEMO_RP_IDWEBAUTHN_DEMO_ORIGINWEBAUTHN_DEMO_USER_IDWEBAUTHN_DEMO_USER_NAME
Backend iOS association identity:
IOS_APP_ID(canonical)IOS_TEAM_ID(optional helper input)IOS_BUNDLE_ID(optional helper input)
Troubleshooting¶
- Signing error about provisioning or the profile:
- Re-select your personal or team signing identity and unique bundle ID.
- Build phase cannot find Gradle task:
- Run from repo root and ensure
sample:compose-passkeyiOS framework targets are configured. - Registration or sign-in fails with domain or association errors:
- Check
IOS_APP_IDalignment andwebcredentials:<domain>entry. - Verify backend serves
/.well-known/apple-app-site-associationfor the exact HTTPS domain. - Simulator works but device passkey flow fails:
- This is usually signing/entitlement/domain mismatch rather than Compose wiring.
Maintaining this project¶
If project.yml changes, regenerate the Xcode project: