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.
- In a terminal window, run the following command to install CocoaPods.
sudo gem install cocoapods
- Create a new Swift project. If you are using an existing project, go to the next step.
- In a terminal window, go to the project directory.
- Run the following command to create a pod file
pod init
Configure the pod files to use the Facebook SDK
- Add the following line to the pod file of your project:
pod 'FacebookCore'
- Open a terminal window and go to your project folder.
- Run the following command to install the Facebook SDK for Swift:
pod install
- 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>
- 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.