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 installin yourios/directory
Installation
1
Install CocoaPods dependencies
After installing the npm package, navigate to your iOS directory and install pods:
2
Configure Info.plist
Add your Facebook App ID, Display Name, and other required keys to
ios/Info.plist:3
Add App Tracking Transparency permission
For iOS 14+, add the App Tracking Transparency usage description:
4
Configure AppDelegate
The configuration differs based on your React Native version:
AppDelegate Configuration
- React Native >= 0.77 (Swift)
- React Native <= 0.76 (Objective-C)
Since React Native 0.77, Swift is natively supported. Configure
AppDelegate.swift:1. Add Required Imports
2. Initialize Facebook SDK
Add this to yourdidFinishLaunchingWithOptions method:3. Add openURL Method for Facebook SSO
4. (Optional) Activate App When It Becomes Active
With Deep Linking (RCTLinkingManager)
If you’re using React Native’s deep linking, modify theopenURL method:Troubleshooting
Undefined symbols for architecture error
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)- Create a new file named
File.swiftin your main project folder - When Xcode prompts you, click “Yes” to create a Bridging Header
- The empty Swift file will automatically configure the Header Search Paths
post_install section of your Podfile:
Login doesn’t work when Facebook app is installed
Make sure you’ve implemented theopenURL 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 yourInfo.plist, add this to didFinishLaunchingWithOptions before the return YES statement:
Duplicate symbol errors
Make sure thatFBSDKCoreKit.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 errorno type or protocol named UIApplicationOpenURLOptionsKey, upgrade to Xcode 10.0 or later.