Don’t have an Auth0 account? Sign up for free and get started with Auth0’s secure authentication and authorization platform.
Get Started
1
Create a new iOS project
Create a new iOS project for this quickstart.In Xcode:
- File → New → Project (or ⌘+Shift+N)
- Select iOS tab → App template
- Configure your project:
- Product Name:
Auth0-iOS-Sample
- Interface: SwiftUI
- Language: Swift
- Use Core Data: Unchecked
- Include Tests: Checked (recommended)
- Product Name:
- Choose a location and click Create
This creates a standard iOS app with SwiftUI and Swift Package Manager support, perfect for Auth0 integration.
2
Add Auth0 SDK via Swift Package Manager
Add the Auth0 iOS SDK to your project using Swift Package Manager.In Xcode:
- File → Add Package Dependencies… (or ⌘+Shift+K)
- Enter the Auth0 iOS SDK URL:
- Add Package → Select your app target → Add Package
- Auth0.swift: Main authentication SDK
- JWTDecode: JWT token parsing utilities
- SimpleKeychain: Secure iOS Keychain wrapper
Swift Package Manager automatically handles dependency resolution and updates. The Auth0 SDK will appear in your Project Navigator under Package Dependencies.
3
Setup your Auth0 App
Next up, you need to:Replace
- Create a new Native Application on your Auth0 tenant
- Configure your iOS app with Auth0 credentials
- Add the Auth0 configuration file to your Xcode project
Create Auth0 Application
- Go to the Auth0 Dashboard
- Click Applications → Create Application
- Name your application (e.g., “My iOS App”)
- Choose Native as the application type
- Click Create
Configure Application Settings
In your Auth0 application settings:- Go to the Settings tab
- Scroll down to Application URIs
- In Allowed Callback URLs, add both URLs below (replace placeholders):
- In Allowed Logout URLs, add the same URLs as above
- Click Save Changes
Create Auth0.plist Configuration
Create a configuration file in your project directory (same level as your.xcodeproj
file) called Auth0.plist
:Auth0.plist
YOUR_AUTH0_CLIENT_ID
and YOUR_AUTH0_DOMAIN
with the actual values from your Auth0 application’s Settings tab.Add Auth0.plist to Xcode Project
- Drag and drop: In Finder, drag the
Auth0.plist
file into your Xcode project navigator - Configure import: In the dialog that appears:
- ✅ Check “Add to target” for your app target
- ✅ Check “Copy items if needed”
- Click Finish
- Verify: The file should now appear in your Xcode project navigator
Important: The plist file must be added to your app target, not just the project. If authentication fails, verify the plist file is included in your target.
4
Create the Authentication Service
Create a centralized service to handle all authentication logic.Add a new Swift file:
- Right-click your project group → New File… → Swift File
- Name it
AuthenticationService
- Replace its contents with:
AuthenticationService.swift
5
Create Login, Logout and Profile Components
Create the UI components that respond to authentication state.Create filesAnd add the following code snippets
6
Configure Associated Domains (Optional)
Skip this step if you’re just getting started. This is for production apps with paid Apple Developer accounts.
Universal Links Setup (Production)
Universal Links Setup (Production)
What are Universal Links?
Universal Links use HTTPS URLs instead of custom URL schemes for enhanced security.Requirements
- Paid Apple Developer account
- iOS 17.4+ or macOS 14.4+
- Xcode 15.3+
Configure Auth0 Dashboard
- Auth0 Dashboard → Applications → Your app → Settings → Advanced Settings → Device Settings
- Add your Apple Team ID and bundle identifier
- Save Changes
Configure Xcode Project
- Select your app target → Signing & Capabilities
- + Capability → Associated Domains
- Add:
webcredentials:YOUR_AUTH0_DOMAIN
7
Run your app
- App launches with “Log In” button
- Tap “Log In” → iOS permission alert → Tap “Continue”
- Safari opens → Complete login → Returns to app
- Success! See your profile information
iOS will show a permission alert for your Auth0 domain. This is normal security behavior - tap Continue.
CheckpointYou should now have a fully functional Auth0 login page running on your iOS simulator or device
Next up:
Secure your API
Integrate the Auth0 SDK on your backend service to authenticate API calls
Build MFA
Go beyond basic authentication and learn how to enable MFA
Troubleshooting & Advanced
Common Issues & Solutions
Common Issues & Solutions
Build errors: ‘Auth0’ module not found
Solutions:- Check Package Dependencies → Verify
Auth0.swift
is listed - Clean and rebuild: ⌘+Shift+K then ⌘+R
- Restart Xcode if needed
App crashes: ‘Auth0.plist not found’
Fix:- Verify
Auth0.plist
is in your Xcode project navigator - Select the file → Inspector → Ensure your app target is checked
- Confirm it has
ClientId
andDomain
keys with your values
Safari opens but never returns to app
Fix:- Check callback URLs in Auth0 Dashboard match your bundle identifier exactly
- Verify bundle identifier in Xcode matches Auth0 settings
- Ensure no typos in URLs (common: missing colons, wrong domain format)
Permission alert appears every time
This is normal iOS security behavior. Consider Universal Links (Step 6) for production apps.Production Deployment
Production Deployment
App Store Preparation
- Configure Associated Domains for Universal Links
- Test on multiple iOS versions and device sizes
- Implement proper error handling for network failures
- Add Privacy Usage descriptions for Keychain access
- Follow App Store Review Guidelines for authentication flows
Security Considerations
- Never log sensitive authentication data in production
- Use Certificate Pinning for additional API security
- Implement App Transport Security (ATS) compliance
- Consider DeviceCheck for fraud prevention
Performance Optimization
- All Auth0 callbacks are dispatched to main queue appropriately
@Published
properties use proper memory handling- App handles authentication state during background/foreground transitions