Installation Guide
This guide provides instructions for installing the OnsideKit framework into your iOS project.
Prerequisites
Xcode 14 or later
iOS 16.0 or later as your project's deployment target
You can integrate OnsideKit using Swift Package Manager, CocoaPods, or by manually adding the framework.
1. Framework Installation 📋
Swift Package Manager
Swift Package Manager (SPM) is Apple's official dependency manager, integrated directly into Xcode.
Steps:
In Xcode, open your project and navigate to your project's settings by clicking on the project file in the Project Navigator.
Select your project in the PROJECT section, then go to the Package Dependencies tab.

Click the + button to add a new package.
In the search bar at the top right, paste the SDK's repository URL:
https://github.com/onside-io/OnsideKit-iOS
Xcode will fetch the package. For the Dependency Rule, we recommend using "Up to Next Major Version" to automatically receive updates and bug fixes without breaking changes.
Click Add Package.

Choose the package product to add to your app's target and click Add Package again.
The OnsideKit framework will now appear in the Project Navigator and will be automatically linked to your target.
CocoaPods
CocoaPods is a popular dependency manager for Swift and Objective-C projects.
Steps:
If you don't have CocoaPods installed, open Terminal and run the following command:
sudo gem install cocoapods
If you don't have a Podfile in your project's root directory, create one by running:
pod init
Open your Podfile with a text editor and add the following line inside your app's target block.
# Podfile platform :ios, '16.0' use_frameworks! target 'YourAppName' do pod 'OnsideKit', :git => 'https://github.com/onside-io/OnsideKit-iOS.git' end
Save the Podfile and run the installation command in your project's root directory:
pod install
After the installation is complete open the newly created .xcworkspace file.
You can now import OnsideKit in your source files and start using the SDK.
Manual Installation
If you prefer not to use a dependency manager, you can install the framework manually.
Steps:
Download the latest version of OnsideKit.xcframework.zip from our Releases page.
Unzip the downloaded file to get the OnsideKit.xcframework bundle.
In Xcode, open your project and select your app's target.
Navigate to the General tab.
Find the "Frameworks, Libraries, and Embedded Content" section.
Drag and drop the OnsideKit.xcframework file from your Finder into this section.
Ensure that "Embed & Sign" is selected for the framework. This is crucial as it bundles the framework with your app and signs it.

2. Basic Configuration 🛠️
To enable the seamless, app-to-app authorization flow with the Onside store app, you need to perform a one-time configuration in your project. This allows your application to securely receive authentication data back from the Onside.
The process involves three main steps:
Step 1: Allow Queries for the Onside App Scheme
For OnsideKit to be able to open the Onside store app, your application needs permission to query for its custom URL scheme. You must add the onside scheme to your app's Info.plist.
In Xcode, open your project's Info.plist file.
Add a new key by clicking the + button and select "Queried URL Schemes" from the list (or type LSApplicationQueriesSchemes manually).
The type for this key will be an Array.
Click the + button on that row to add a new item to the array.
Set the value of Item 0 to onside.
This is what it looks like in the Info.plist source code:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>onside</string>
</array>
Why is this needed? This step is required by iOS to allow your app to check if the main Onside store app is installed on the user's device (canOpenURL), which is necessary to initiate the seamless login flow.
Step 2: Declare a Custom URL Scheme
Your app needs a unique identifier so the Onside store app knows where to redirect the user back to. This is done by registering a custom URL scheme.
In Xcode, select your project file in the Project Navigator.
Select your app's target and navigate to the Info tab.
Expand the URL Types section. If it doesn't exist, click the + button to add one.
In the URL Schemes field, enter a unique scheme for your app. We recommend using a reverse-domain style or a unique name related to your app to avoid collisions with other apps.
Example: com.yourapp.auth or onside-yourapp-login
Step 3: Provide the Callback Scheme to the SDK
Once the URL scheme is declared, you must provide the exact same string to OnsideKit. This allows the SDK to correctly handle the callback.
The best place to do this is at application launch.
Open your AppDelegate.swift file
Import the OnsideKit framework
In the application(_:didFinishLaunchingWithOptions:) method, set the callbackScheme property on the Onside
// AppDelegate.swift
import UIKit
import OnsideKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Use the exact same URL Scheme you defined in your Info.plist
Onside.callbackScheme = "com.yourapp.auth"
// Your other app setup code...
return true
}
// ... rest of your AppDelegate code
}
Step 4: Forward Incoming URLs to the SDK
When the Onside app redirects back to your application, the system will notify your app via a specific delegate method. You need to implement this method and pass the incoming URL to OnsideKit to complete the authentication process.
The implementation depends on your project's lifecycle (UIKit AppDelegate or SwiftUI App).
For UIKit AppDelegate Lifecycle
In your AppDelegate.swift, implement the application(_:open:options:) method.
// AppDelegate.swift
import OnsideKit
class AppDelegate: UIResponder, UIApplicationDelegate {
// ... your other AppDelegate code
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let handledByOnside = Onside.handle(url: url)
if handledByOnside {
return true
} else {
// Your other url handling code...
}
}
}
For SwiftUI App Lifecycle (with SceneDelegate)
If your project uses a SceneDelegate, you should implement the scene(_:openURLContexts:) method instead.
// SceneDelegate.swift
import OnsideKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// ... your other SceneDelegate code
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url else {
return
}
let handledByOnside = Onside.handle(url: url)
if !handledByOnside {
// Your other url handling code...
}
}
}
3. Congratulations! 🎉
You've completed the necessary configuration! You are now ready to start using OnsideKit in your application.
Last updated
Was this helpful?