Step 2. Integrate the SDK into your app
To initialize the ForgeRock iOS SDK for your application, perform one of these procedures:
Method 1. Install using CocoaPods (recommended)
CocoaPods is a dependency manager for iOS projects. CocoaPods provides developers with a simple way to integrate the ForgeRock iOS SDK into their project.
-
If you do not already have CocoaPods, install the latest version of CocoaPods.
-
In a terminal window, navigate to your project’s root folder.
cd /path/to/DemoApp
-
Run
pod init
. -
Edit the resulting
Podfile
:-
On the line after the
# Pods for DemoApp
comment, enterpod 'FRAuth'
# Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'DemoApp' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for DemoApp pod 'FRAuth' target 'DemoAppTests' do inherit! :search_paths # Pods for testing end target 'DemoAppUITests' do # Pods for testing end end
-
Save your changes.
-
-
Run
pod install
.Your
DemoApp
project should now include aDemoApp.xcworkspace
file.When you install the SDK using CocoaPods, you must always open your project using this workspace file.
-
In Xcode, open the
DemoApp.xcworkspace
workspace file.Xcode opens and displays the workspace that contains your project.
-
In the left panel, verify that the
FRAuth
pod appears under Pods > Pods:Figure 1. FRAuth pod in an Xcode workspace -
To ensure your project builds, select the project and click the Start/Run arrow icon.
Xcode should display a device simulator.
You are now ready to develop your app using the ForgeRock SDK for iOS. Proceed to Step 3. Initialize the SDK.
Method 2. Install using Swift Package Manager
Swift Package Manager is a dependency management tool for Swift code. Swift Package Manager allows developers to integrate the ForgeRock SDK for iOS into their Xcode project.
-
From the Xcode menu, select File > Add Package Dependencies.
-
In the search bar, enter the ForgeRock SDK for iOS repository URL:
https://github.com/ForgeRock/forgerock-ios-sdk
. -
Select the
forgerock-ios-sdk
package. -
From the Dependency Rule drop-down, select Exact Version, and in the version field, enter
4.5.0
.Only versions 3.0.0 and newer of the ForgeRock SDK for iOS is only available in the Swift Package Manager. For versions 2.2.0 and earlier, use CocoaPods instead. -
Click Add Package.
-
In the Choose Package Products for forgerock-ios-sdk dialog:
-
Select
FRAuth
,FRCore
-
Select any extra packages your app needs
-
Click Add Package.
-
-
Verify that the modules you selected appear in the left menu.
You are now ready to develop your app using the ForgeRock SDK for iOS. Proceed to Step 3. Initialize the SDK.
Method 3. Embed the source code in your project
To embed the SDK source code in your project:
-
Clone the ForgeRock SDK for iOS repository:
git clone https://github.com/ForgeRock/forgerock-ios-sdk.git
-
In Xcode, in the left navigation panel, right-click on your project and select Add Files to "DemoApp".
-
Browse to the
FRAuth.xcodeproj
file in the ForgeRock SDK for iOS project, and then click Add.For example,
/path/to/forgerock-ios-sdk/FRAuth/FRAuth.xcodeproj
-
In the left navigation panel, select DemoApp, and in the Targets panel, select the DemoApp target.
-
In the Frameworks, Libraries and Embedded Content section, click Add (+), select
FRAuth.framework
, and then click Add.Figure 2. Adding theFRAuth.framework
package to your app project
You are now ready to develop your app using the ForgeRock SDK for iOS. Proceed to Step 3. Initialize the SDK.