Facebook Analytics Getting Started Guide for iOS Swift

When you integrate the Facebook SDK for Swift, you can see the data collected by Facebook Analytics in your app dashboard. This topic assumes you use CocoaPods as the dependency manager for your Swift Cocoa projects. For more information about CocoaPods with you Swift app, see the Getting Started guide at https://guides.cocoapods.org/using/getting-started.html.

If you wrote your app using Objective-C, see Facebook Analytics for iOS-Quickstart to learn how to integrate the Facebook SDK for iOS to use Facebook Analytics.

Installing CocoaPods

This section shows how to install CocoaPods and create a pod file. If you already installed CocoaPods and created a pod file, go to the next section.

  1. In a terminal window, run the following command to install CocoaPods.
    sudo gem install cocoapods
  2. Create a new Swift project. If you are using an existing project, go to the next step.
  3. In a terminal window, go to the project directory.
  4. Run the following command to create a pod file
    pod init

Configure the pod files to use the Facebook SDK

  1. Add the following line to the pod file of your project:
    pod 'FacebookCore'
  2. Open a terminal window and go to your project folder.
  3. Run the following command to install the Facebook SDK for Swift:
    pod install
  4. Configure your information property list.
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>fb[APP_ID]</string>
      </array>
      </dict>
    </array>
    <key>FacebookAppID</key>
    <string>[APP_ID]</string>
    <key>FacebookDisplayName</key>
    <string>[APP_NAME]</string>
  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.

Take a Guided Tour of Facebook Analytics

Now that you're logging app events, visit our demo app to take a guided tour of all of the key features that Facebook Analytics offers you and your business.

The demo app does not have an Event Debugging link. This link is only available in apps that you create.

Next Steps

Be sure to check out our other documentation pages for more advanced guides.