ForgeRock Developer Experience

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.

  1. If you do not already have CocoaPods, install the latest version of CocoaPods.

  2. In a terminal window, navigate to your project’s root folder.

    cd /path/to/DemoApp

  3. Run pod init.

  4. Edit the resulting Podfile:

    1. On the line after the # Pods for DemoApp comment, enter pod '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
    2. Save your changes.

  5. Run pod install.

    Your DemoApp project should now include a DemoApp.xcworkspace file.

    When you install the SDK using CocoaPods, you must always open your project using this workspace file.

  6. In Xcode, open the DemoApp.xcworkspace workspace file.

    Xcode opens and displays the workspace that contains your project.

  7. In the left panel, verify that the FRAuth pod appears under Pods > Pods:

    xcode pods en
    Figure 1. FRAuth pod in an Xcode workspace
  8. 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.

  1. From the Xcode menu, select File > Add Package Dependencies.

  2. In the search bar, enter the ForgeRock SDK for iOS repository URL: https://github.com/ForgeRock/forgerock-ios-sdk.

  3. Select the forgerock-ios-sdk package.

  4. 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.
  5. Click Add Package.

  6. In the Choose Package Products for forgerock-ios-sdk dialog:

    1. Select FRAuth, FRCore

    2. Select any extra packages your app needs

    3. Click Add Package.

  7. 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:

  1. Clone the ForgeRock SDK for iOS repository:

    git clone https://github.com/ForgeRock/forgerock-ios-sdk.git

  2. In Xcode, in the left navigation panel, right-click on your project and select Add Files to "DemoApp".

  3. 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

  4. In the left navigation panel, select DemoApp, and in the Targets panel, select the DemoApp target.

  5. In the Frameworks, Libraries and Embedded Content section, click Add (+), select FRAuth.framework, and then click Add.

    xcode add frauth en
    Figure 2. Adding the FRAuth.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.