Installing with Swift

Step 1: Installing the SDK Using Swift

  1. Download the latest version of the Fyber SDK. Feel free to check the changelog.

  2. Drag the fyber-sdk-lib folder from a Finder window to your project’s Xcode window. You'll find this folder in the previously downloaded zip.

  3. Xcode will display a popup, prompting for more details about what to do with the dropped folder. Make sure that Create groups is checked as well as your application's target in the Add to targets section:


Make sure the static library is listed in the Link Binary with Libraries section of your target’s Build Phases.

  1. Xcode 5 build with modules is enabled by default. You can check this in the project Build Settings Panel. Search for “Module” and verify if Enable Modules (C and Objective-C) is set to Yes. Based on that, select one of the following options:

Step 2: Adding a Bridging Header

  1. Next, in your project create a header called YOUR_PROJECT-Bridging-Header.h that imports the FyberSDK header.

  1. Configure your project to use the bridging header you just created. For this go to the setting of your application’s target and set the Objective-C Bridging Header to where the header is located.

Step 3: Adding User Consent 


The General Data Protection Regulation requires you to scope your user's consent. A user is within the GDPR scope for your app when one or all of the following apply:

  • The user is currently located in the EU
  • The user has registered with the app as an EU resident
  • The app is specifically targeted to EU users

Once you have collected the user’s consent, you can pass it onto the SDK using the following API:

let userConsent = ...

userConsent should be Yes if you have the user’s consent, or No otherwise.

If you don’t pass the user’s consent to the SDK, only contextual ads will be shown to that user.

We recommend that the first time you gather the user’s consent, you pass it onto the SDK before starting the SDK. The SDK will then take the user’s consent into consideration when initializing. In the following sessions, you will only need to call the API if the user updates his or her consent.

More information on GDPR can be found under the GDPR Resource Page and FAQs.

For details of the CCPA - Privacy String, click here.

CCPA - Privacy String

The intention of the California Consumer Privacy Act of 2018 (CCPA) is to protect the personal information of California residents. CCPA applies to all companies doing business in California. If a California resident uses an app developer’s mobile app, CCPA applies to the developer and every company that processes the personal information of the app’s users.
CCPA came into effect on 1 January 2020.

For more information on Fyber and CCPA, refer to Fyber’s Resource Page.
For more information about CCPA, refer to the IAB CCPA Compliance Framework.

Setting the IAB US Privacy String

We recommend that the first time you gather a user opt-out (aka 'consent'), you pass it onto the SDK before initializing it. The SDK takes the user opt-out into consideration when initializing.

Once you have collected the user’s opt-out, you can pass it onto the SDK using the following API:

To set the IAB US privacy string, use the following API:

[[FyberSDK instance].user setIABUSPrivacyString:@"1YNN"];
Clearing Privacy Opt-Out

To clear the user opt-out setting, use the following API:

[[FyberSDK instance].user clearIABUSPrivacyString];

Step 4: Starting the SDK

Start the Fyber SDK before using any Fyber product.


You must initialize the SDK on app start for accurate DAU calculations.

To do this, determine a point in your application’s code that is run once. A good example point is the application:didFinishLaunchingWithOptions: method in your application delegate.

let options = FYBSDKOptions(appId: "00000", userId: "userId", securityToken: "000000000000000000000000")
FyberSDK.start(with: options)

The Security Token and appId are required, and can be found in the Settings of your app in the Dashboard. The User ID should uniquely identify the user of your app.


Check that the userID is not hardcoded and is completely unique for each user.

An Alternate Option

The previous method is our preferred method of starting the SDK.

If you do not want to set a userId yourself and prefer that the Fyber SDK creates it for you, the Fyber SDK can do so when you include the following in your code:

let options = FYBSDKOptions(appId: "00000", securityToken: "000000000000000000000000")
FyberSDK.start(with: options)

This generates the required unique userId on the first launch of the application and stores it for subsequent launches.

Subsequent usage of the Fyber SDK during your application's lifecycle reuses the parameters passed to this call. If the user re-installs the app, a new userId is generated.


Using optionsWithAppId:securityToken is not Fyber's preferred method to start the SDK, especially if you are planning to user server-side callbacks to handle the user rewarding.

Installing with Cocoapods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like FyberSDK in your projects.

See the CocoaPods Getting Started and Using CocoaPods for more information.

Add the following pod:

pod 'FyberSDK', '~> 9.2.1'

Now you may start the SDK, refer to either Objective-C or Swift instructions

Back to Top ⇧