Skip to main content

Prerequisites

Before setting up the iOS SDK, ensure you have:
  • Completed the Facebook App Setup (steps 2, 3, and 4)
  • Added the library via npm/yarn
  • Run pod install in your ios/ directory

Installation

1

Install CocoaPods dependencies

After installing the npm package, navigate to your iOS directory and install pods:
cd ios && pod install
2

Configure Info.plist

Add your Facebook App ID, Display Name, and other required keys to ios/Info.plist:
<key>FacebookAppID</key>
<string>YOUR_APP_ID</string>
<key>FacebookDisplayName</key>
<string>YOUR_APP_NAME</string>
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>fbYOUR_APP_ID</string>
    </array>
  </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-share-api</string>
</array>
3

Add App Tracking Transparency permission

For iOS 14+, add the App Tracking Transparency usage description:
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
4

Configure AppDelegate

The configuration differs based on your React Native version:

AppDelegate Configuration

Since React Native 0.77, Swift is natively supported. Configure AppDelegate.swift:

1. Add Required Imports

import FBSDKCoreKit              // <- Add This Import
import AppTrackingTransparency   // <- Add This Import

// Remove this if present:
// import FacebookCore           // <- REMOVE if present

2. Initialize Facebook SDK

Add this to your didFinishLaunchingWithOptions method:
public override func application(
  _ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
  
  // ... your existing code ...
  
  // Initialize Facebook SDK
  ApplicationDelegate.shared.application(
    application,
    didFinishLaunchingWithOptions: launchOptions
  )
  
  // Request App Tracking Transparency authorization (iOS 14+)
  if #available(iOS 14, *) {
    ATTrackingManager.requestTrackingAuthorization { _ in
      AppEvents.shared.activateApp()
    }
  } else {
    AppEvents.shared.activateApp()
  }
  
  // ... rest of your code ...
  
  return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

3. Add openURL Method for Facebook SSO

This method is required for Facebook login to work when the Facebook app is installed on the device.
public override func application(
  _ app: UIApplication,
  open url: URL,
  options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
  // Facebook SDK must be checked FIRST
  let handledByFB = ApplicationDelegate.shared.application(
    app, open: url, options: options)
  
  // Then call super
  let handledBySuper = super.application(
    app, open: url, options: options)
  
  return handledByFB || handledBySuper
}

4. (Optional) Activate App When It Becomes Active

open override func applicationDidBecomeActive(_ application: UIApplication) {
  super.applicationDidBecomeActive(application)
  AppEvents.shared.activateApp()
}

With Deep Linking (RCTLinkingManager)

If you’re using React Native’s deep linking, modify the openURL method:
The order is critical: FBSDKApplicationDelegate must be checked before RCTLinkingManager. If RCTLinkingManager is placed first, it will intercept the Facebook SSO callback URL and treat it as a regular deep link, breaking Facebook Single Sign-On functionality.
public override func application(
  _ app: UIApplication,
  open url: URL,
  options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
  // IMPORTANT: Facebook SDK must be checked FIRST
  let handledByFB = ApplicationDelegate.shared.application(
    app, open: url, options: options)
  
  // Then React Native Linking
  let handledByRN = RCTLinkingManager.application(
    app, open: url, options: options)
  
  // Finally super
  let handledBySuper = super.application(
    app, open: url, options: options)
  
  return handledByFB || handledByRN || handledBySuper
}

Troubleshooting

Undefined symbols for architecture error

If you encounter a build error with “Undefined symbols for architecture x86_64”, you need to create a Bridging Header.
After facebook-ios-sdk v7 (written with Swift), you need to coordinate Swift language usage with Objective-C: Solution 1: Create a Bridging Header (Recommended)
  1. Create a new file named File.swift in your main project folder
  2. When Xcode prompts you, click “Yes” to create a Bridging Header
  3. The empty Swift file will automatically configure the Header Search Paths
Solution 2: Add Podfile Workaround Add this to the post_install section of your Podfile:
# Mixing Swift and Objective-C in a react-native project may be problematic.
# Workaround: https://github.com/facebookarchive/react-native-fbsdk/issues/755
installer.aggregate_targets.first.user_project.native_targets.each do |target|
  target.build_configurations.each do |config|
    config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(inherited)', '$(SDKROOT)/usr/lib/swift']
  end
end
Then run:
pod deintegrate && pod install

Login doesn’t work when Facebook app is installed

Make sure you’ve implemented the openURL method correctly. Without it, the Facebook app cannot redirect back to your app after authentication. See: GitHub Issue #59

App ID not found error

If you get an exception about App ID not found, and you’re certain it’s in your Info.plist, add this to didFinishLaunchingWithOptions before the return YES statement:
[[FBSDKApplicationDelegate sharedInstance] application:application
                      didFinishLaunchingWithOptions:launchOptions];

Duplicate symbol errors

Make sure that FBSDKCoreKit.framework, FBSDKLoginKit.framework, and FBSDKShareKit.framework are not in Link Binary with Libraries for your root project when using CocoaPods.

Xcode version too old

If you get the error no type or protocol named UIApplicationOpenURLOptionsKey, upgrade to Xcode 10.0 or later.

Next Steps

Once iOS setup is complete, you can:

Build docs developers (and LLMs) love