iOS SDK
This SDK allows you to integrate Reclaim's in-app verification process into your SwiftUI application.
Prerequisites
- An iOS application source code (Support for iOS 13 or later).
- An iOS device running iOS 13 or later.
- A Reclaim account where you've created an app and have the app id, app secret.
- A provider id that you've added to your app in Reclaim Devtools.
Example
- See the Reclaim Example - SwiftUI for a complete example of how to use the SDK in a SwiftUI application.
Installation
1. Adding Reclaim InApp SDK to your Xcode Project
Method 1: When working with an Xcode project (Recommended):
Copy the following URL and use it to add Swift Package Manager (SPM) dependency into the Xcode project:
How to add a Swift Package Manager (SPM) dependency to your Xcode project:
- In your Xcode Editor's toolbar, click on
File
>Add Package Dependency...
.

- In the
Add Package Dependency
dialog box, paste the URLhttps://github.com/reclaimprotocol/reclaim-inapp-ios-sdk.git
into theSearch or Enter package URL
field on the top right corner of dialog box.

- Click
Add Package
. - In the other window, select your app target in the
Add to Targets
section and then clickAdd package
.

This should complete the installation of the Reclaim InApp SDK. Now follow the steps below to link the necessary frameworks to your Xcode project.
Note
- It's worth noting that you should commit the swiftpm folder that will be built and more specifically that the Package.resolved file should be included in your source control/git.
Method 2: When working with an Xcode Workspace project with CocoaPods:
- Make sure to define a global platform for your project in your
Podfile
with version 13.0 or higher.
- Add the following to your
Podfile
:
- From a specific tag (recommended):
- or from git HEAD (Alternative):
- or from a specific commit (Alternative):
- or from a specific branch (Alternative):
- After adding the dependency, your podfile may look like this:
- Run
pod install
. - Open the
*.xcworkspace
file to work on the project. And build the project. - Your build may fail due to an error like this:

- To fix this, open the
*.xcworkspace
file in Xcode. In your target'sBuild Settings
, underBuild Options
Section, setUser Script Sandboxing
toNo
and build the project again.

- Your project should build successfully.
Method 3: When working with a Swift Package Manager manifest:
Either select a package version:
Or select the main branch:
Select a product:
- ReclaimInAppSdk
Build the project.
- If you have a
*.xcworkspace
then openYourApp.xcworkspace
in Xcode. Verify that you're opening MyApp.xcworkspace and not opening MyApp.xcodeproj. The .xcworkspace file has the CocoaPod dependencies, the .xcodeproj doesn't. If you don't have a*.xcworkspace
then openYourApp.xcodeproj
in Xcode. - Select Product > Build or press
Cmd + B
.
2. Fixing performance issues
Your app performance will be severely impacted when you run debug executable on a physical device. Fixing this requires a simple change in your Xcode project xcscheme.
Method 1: Update Environment Variables for XCScheme (Recommended)
- Open your project in Xcode.
- Click on the project target.
- Click on the Scheme dropdown.

- Click on the Edit Scheme button.
- Click on the Run tab.
- Click on the Arguments tab and check the Environment Variables section.

- Add the following environment variable:
- Key:
GODEBUG
- Value:
asyncpreemptoff=1
- Key:
- Click on the Close button in the dialog and build the project.
- Run the app on a physical device.
Method 2: Disable "Debug executable"
This method is not recommended but could be useful if you don't want to add environment variables to the xcscheme.
- Open your project in Xcode.
- Click on the project target.
- Click on the Scheme dropdown.

- Click on the Edit Scheme button.
- Click on the Run tab.
- Uncheck the Debug executable checkbox.

4. Use ReclaimInAppSdk in your project
To use ReclaimInAppSdk in your project, follow these steps:
- Import the ReclaimInAppSdk module into your Swift file.
- Create a request object.
More ways to create a request object are available in the ReclaimVerification.Request.*
apis.
- Start the verification flow.
The returned result is a ReclaimVerification.Response
object. This object contains a response that has proofs, exception, and the sessionId if the verification is successful.
If the verification is cancelled or failed, the result will contain an exception.
You can use the ReclaimVerification.Response
object to get the proof, exception, and sessionId.
If the verification is successful, the proof will contain the data that you need to store in your database.
If the verification is cancelled or failed, the exception will contain the error details.
In the above apis, ReclaimVerification.Request.*
, ReclaimVerification.startVerification
or ReclaimVerification.startVerificationFromUrl
can also throw an error. The error can be one of the following:
ReclaimVerificationError.cancelled
: The verification was cancelled by the user.ReclaimVerificationError.dismissed
: The verification was dismissed by the sdk.ReclaimVerificationError.failed(let error)
: The verification failed due to an error.ReclaimVerificationError.sessionExpired
: The verification session expired.
You can handle the error by using a do-catch
block. For example:
For a complete example, see the Reclaim Example - SwiftUI.
Overrides | Advanced Usage
You can use the ReclaimOverrides
to customize the verification flow with ReclaimVerification.setOverrides
.
Upgrading
To upgrade to a new version of the Reclaim InApp SDK, follow these steps:
- Make sure you have the latest version of the Reclaim InApp SDK. Currently the latest version is
v0.1.2
. - Incase of any problems: remove package, clear build, restart Xcode, and add package again.
Migration guides will be available when a new version with API changes is released.