Skip to content

Getting Started with Swift

Create an iOS Project

To get started using Openfort with iOS, create a new project in Xcode. Select Swift as your language. See the Xcode documentation for more information.

Install the Openfort iOS SDK

Follow the Swift Package Manager instructions to install Openfort as a dependency. When prompted for the package URL, enter https://github.com/openfort-xyz/swift-sdk.git. Be sure to add the package to your target.

Set up auth providers

Navigate to the auth providers page on the Openfort dashboard by selecting your project and clicking Auth Providers Methods in the side bar in the users page. Select the account types you'd like users to be able to login with.

Import the Framework

import OpenfortSwift

Get your Openfort keys

From the Openfort Dashboard, select your desired app and navigate to the developers page. You'll need:

  • Publishable Key: Safe to expose in client-side environment
  • Secret Key: Must be kept secure and used only server-side
  • Shield Keys: Required for non-custodial wallets
    • Create Shield keys in the Shield section
    • Securely store the encryption share shown in the one-time popup
    • You'll get both a Publishable and Secret Shield key

Configure OFConfig.plist

  1. Download the OFConfig.plist and add it to your Xcode project.
  2. Make sure to select “Copy items if needed” when prompted.
  3. Open the file in Xcode and configure the following keys with your values:
  • backendURL – Your backend API base URL (optional)
  • iframeURL – URL of your iframe environment (optional)
  • openfortPublishableKey – Your Openfort publishable key (required)
  • shieldPublishableKey – Your Shield publishable key (required)
  • shieldURL – Shield service URL (optional)

Initialize the SDK

In your AppDelegate.swift:

import UIKit
import OpenfortSwift
 
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        OFSDK.setupSDK()
        return true
    }
}

Next Steps

Now that you've configured your app, you can use OFSDK.shared throughout to access the Openfort SDK.