Get Started - Facebook SDK for iOS

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

Before You Start

This procedure assumes you are using the latest version of iOS and Xcode. Learn more at the Apple Developer.

Note: To follow these instructions, you will need to create a project with UIKit App Delegate selected for Life Cycle. The following image shows an example:

You will need:

  • A Facebook for Developers Account If you need one, click this button and follow the steps.
Create a Facebook for Developers Account

  • An App ID for Your App click this button and follow the steps to register your app and get an App ID
Get an App ID for your app

Step 1: Set Up Your Development Environment

  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 the default option.
  4. Complete the prompts to select the libraries you want to use in your project.

Step 2: Configure Your Project

Configure the Info.plist file 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. In <array><string> in the key [CFBundleURLSchemes], replace [APP_ID] with your App ID.
  4. In <string> in the key FacebookAppID, replace [APP_ID] with your App ID.
  5. In <string> in the key FacebookDisplayName, replace [APP_NAME] with the name of your app.
  6. 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 3: Connect the App Delegate

Replace the code in `AppDelegate` with the following code. This code initializes the SDK when your app launches, and allows the SDK handle results from the native Facebook app when you perform a Login or Share action:
// Swift
// AppDelegate.swift
import UIKit
import FBSDKCoreKit

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
            didFinishLaunchingWithOptions: launchOptions

        return true
    func application(
        _ app: UIApplication,
        open url: URL,
        options: [UIApplication.OpenURLOptionsKey : Any] = [:]
    ) -> Bool {

            open: url,
            sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
            annotation: options[UIApplication.OpenURLOptionsKey.annotation]


// Objective-C
// AppDelegate.m  
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [[FBSDKApplicationDelegate sharedInstance] application:application
  return YES;

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
  [[FBSDKApplicationDelegate sharedInstance] application:application
  return YES;
If you are using iOS 13 or above please add the following method to your `SceneDelegate`:
// Swift
// SceneDelegate.swift
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    guard let url = URLContexts.first?.url else {

        open: url,
        sourceApplication: nil,
        annotation: [UIApplication.OpenURLOptionsKey.annotation]

// Objective-C
// SceneDelegate.m
#import <FBSDKCoreKit/FBSDKCoreKit.h>

@import FacebookCore;

@interface SceneDelegate ()


@implementation SceneDelegate

- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts
  UIOpenURLContext *context = URLContexts.allObjects.firstObject;
  [FBSDKApplicationDelegate.sharedInstance application:UIApplication.sharedApplication

Step 4: 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 5: 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