Facebook Announces Open-Source Swift SDK Beta for iOS

| by Sergio De Simone Follow 21 Followers on Jul 17, 2016. Estimated reading time: 1 minute |

Now available in beta, Facebook’s new SDK for Swift aims to make it easier for developers to integrate Facebook services into their iOS apps.

Facebook Swift SDK for Swift includes support for a number of Facebook services, including Facebook Analytics, Facebook Login, Share for Facebook, and Facebook Graph API. It is based on the existing Objective-C Facebook SDK, around which it builds a collection of wrappers aiming to provide a native Swift API and easier developer experience.

Facebook Swift SDK includes support for the two most popular package management systems for iOS/macOS, CocoaPods and Carthage. To include it into your app using CocoaPods, ensure your Podfile looks something like this:

target "YourXcodeTargetNameHere" do


  pod 'FacebookCore'
  pod 'FacebookLogin'
  pod 'FacebookShare'

  ## other pod files here as required

If you use Carthage, you can add the following line to your Cartfile:

github "facebook/Facebook-SDK-Swift"

Alternatively, you can include Facebook Swift SDK as a subproject into your Xcode project, although this approach will require you to take care of all dependencies, namely FBSDKCoreKit.framework, FBSDKLoginKit.framework, and FBSDKShareKit.framework, and their updates.

Facebook Swift SDK repo on GitHub includes a sample project showing how you can integrate supported services into your app. This is for example how you can share a photo using the provided ShareDialogViewController:

let photo = Photo(image: UIImage(named: "sky.jpg")!, userGenerated: true)
let content = PhotoShareContent(photos: [photo])

let dialog = ShareDialog(content: content)
dialog.presentingViewController = self
dialog.mode = .Automatic
do {
} catch (let error) {
    let alertController = UIAlertController(title: "Invalid share content", message: "Failed to present share dialog with error \(error)")
    presentViewController(alertController, animated: true, completion: nil)

Facebook Swift SDK targets Swift 2.2.1 and 2.3, allowing thus developers to submit apps to the App Store, while support for Swift 3 is scheduled for later this year when Swift 3 reaches GM.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Doesn't work by Dylan Fernando

Unable to find a specification for `FacebookCore`

reply by shalini ranganathan

your coding and sayings are really awesome and thus it is very much useful and it is highly relevant

Re: Doesn't work by James Hubert

Have you figured this out? I'm having the same issue.

use_frameworks! by Joe Parks

Have you tried it with the "use_frameworks!" directive?
From the getting started guide:

To use the SDK with CocoaPods, add the following lines to your Podfile:


pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'

Re: Doesn't work by Sergio De Simone

I guess you did not specify a target in your Podfile. That should go like this:

target "testTarget" do
-- your cocoa pods here --

Re: Doesn't work by Sergio De Simone

Please, see my reply to Dylan Fernando. Hope it helps.

Re: Doesn't work by Fabiola Werneck

Hey! Just update the cocoapods version using
sudo gem install cocoapods

Facebook SDK in Swift supports CocoaPods 1.0.1 or later.


Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

7 Discuss