Get Started - Facebook SDK for iOS

The Facebook SDK for iOS is the easiest way to integrate your iOS app with Facebook. It enables:

Step 1: Set Up Your Development Environment

In the following list, select the appropriate SDK for the language you will use in this app. If your app uses Swift, select SDK: Cocoapods. If your app uses Objective-C, select SDK: FB SDK.
Using Swift Package Manager (SPM)
Only available for Xcode 11.2 and above.
  1. In Xcode, click File > Swift Packages > Add Package Dependency.
  2. In the dialog that appears, enter the repository URL:
  3. In Version, select Up to Next Major and take the default option.
  4. Complete the prompts to select the libraries you'd like to use in your project.
  5. To use the Objective-C interface exclusively, import the 'FBSDK'-prefixed module.
    Example: import FBSDKCoreKit
    To use the enhanced Swift interface in your code, import the 'Facebook'-prefixed module.
    Example: import FacebookCore
1. Install Cocoapods.
If you already installed Cocoapods and created a pod file, go to the next step to install the Facebook SDK. To install Cocoapods, open a terminal window and run the following command in a terminal window:
sudo gem install cocoapods
2. Install the Facebook SDK.
  1. Create a new Swift project and go to the project directory. If you are using an existing project, go to project directory of the existing project.
  2. In a terminal window, run the following command to create a pod file for the project:
    pod init
  3. Add the following line to the pod file of your project:
    pod 'FBSDKCoreKit/Swift'
  4. In the terminal window, run the following command to install the Facebook SDK for Swift:
    pod install
3. Modify the AppDelegate.swift file:
  1. Add the following import statement:
  2. import FBSDKCoreKit
  3. Add the following statement to the applicationDidBecomeActive function:
  4. AppEventsLogger.activate(application)
Your Cartfile should look something like:

github "facebook/facebook-ios-sdk"

Using the Facebook SDK

Download the SDK and unzip the archive to ~/Documents/FacebookSDK.

Step 2: Register and Configure Your App with Facebook

Add Your Bundle Identifier and enable Single Sign-On for your App

The bundle identifier (Bundle ID) should appear in the box below. If the box is empty, find your bundle identifier in your Xcode Project's iOS Application Target and paste it into the box below.
Bundle ID
You can change your bundle identifier in the future via the iOS section on the settings page.
Enable Single Sign On
Enable single sign on for your app by setting Single Sign On to Yes below.
Single Sign On Will launch from iOS Notifications

Step 3: Configure Your Project

Configure the information property list file (info.plist) with an XML snippet that contains data about your app.
  1. Right-click info.plist, and choose Open As Source Code.
  2. Copy and paste the following XML snippet into the body of your file ( <dict>...</dict>).
  3. To use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, your application's info.plist also needs to include: <dict>...</dict>).

Step 4: Connect App Delegate and Scene Delegate

Add the following to your AppDelegate class. This initializes the SDK when your app launches, and lets the SDK handle results from the native Facebook app when you perform a Login or Share action:
//  AppDelegate.m
#import <FBSDKCoreKit/FBSDKCoreKit.h>

- (BOOL)application:(UIApplication *)application 
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [[ApplicationDelegate sharedInstance] application:application
  // Add any custom logic here.
  return YES;

- (BOOL)application:(UIApplication *)application 
            openURL:(NSURL *)url 
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {

  BOOL handled = [[ApplicationDelegate sharedInstance] application:application
  // Add any custom logic here.
  return handled;
If your app has a SceneDelegate (new for iOS 13 and Xcode 11), you will also need to add the following to that class:
//  SceneDelegate.m
#import <FBSDKCoreKit/FBSDKCoreKit.h>

- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
  UIOpenURLContext *openURLContext = URLContexts.allObjects.firstObject;
  if (openURLContext) {
    [[ApplicationDelegate sharedInstance] application:UIApplication.sharedApplication
  // Add any custom logic here.
If your app has support for iOS 8, you will also need to add the following to the AppDelegate:
- (BOOL)application:(UIApplication *)application 
            openURL:(NSURL *)url 
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {

  BOOL handled = [[ApplicationDelegate sharedInstance] application:application
  // Add any custom logic here.
  return handled;

Step 5: Build and Then Run Your Project in the Simulator

In Xcode, select an iOS simulator and click Run. Xcode builds your project and then launches the most recent version of your app running in Simulator.

Step 6: See the Results in Events Manager

The Events Manager displays the events you send to Facebook Analytics. If this is the first time you launched your app with this code, you may have to wait at least 20 minutes before your events appear.
Note: Events may take up to 20 minutes to appear in the dashboard.

Next Steps

To learn how to implement App Events and other Facebook products to your app, click one of the buttons below.

Sharing in iOSAdd Facebook LoginAdd App EventsUse Graph API
Advanced Configuration