Kyle's Place somewhere to put my thoughts

Getting Started: Swift 2 and Facebook SDK 4.8.0

I was starting a new Swift 2 project and saw the Facebook developer portal did not cover Swift. I figured I would take it upon myself to fill in some of the missing pieces of the tutorial found on developer.facebook.com. Full sample project on Github.

Importing the Facebook SDK frameworks into the project:

Download the Facebook SDK add the necessary framework files to your project. You will need to select “Copy items if needed” when adding the files to your project (click Options if now showing). Add files to project

Configure your .plist

Add the following to info.plist (right click, Open As > Source Code) inside the <dict>...</dict> tag:

Add the Facebook framework to your App Delegate

In your AppDelegate.swift import FBSDKShareKit and add a new application function.

Add login button to your View Controller

In one of your ViewController.swift files import FBSDKLoginKit and add the login button to the viewDidLoad() function.

Test your program

Run your application on the emulator or on a device and you should see a Facebook login button that will direct you to login. Logging in will store your application in your Facebook account’s Apps section as an authorized application. Inside the Swift application you now have a logout button instead of a login button. Add files to project