Advanced Topics - Facebook SDK for iOS

- Create a Simulator Build

- Build from Source

- Swift

- Advanced App Configuration

Create a Simulator Build (for App Review)

If you create an app that uses Facebook Login you need to submit for review. See Review Guidelines.

For iOS apps, you should generate a simulator binary package and upload it for us to use as part of the review process. To generate a simulator build:

1. Step: Run App in Simulator

Run your app in your Xcode iPhone simulator. This automatically creates a simulator build in Xcode's DerivedData cache.

2. Step: ZIP Simulator Build

Zip your simulator build by navigating to the file in Finder, right-clicking the file, and clicking Compress.


3. Step: Verify Build

You can verify the simulator build by using the ios-sim utility Command-line App Launcher for Simulator. Once installed run:

ios-sim launch /path/to/your-app.app

4. Step: Submit for Review

Submit file zip file (e.g. YourApp.zip) using your app dashboard. Please note that we delete the simulator build you provide three weeks after your submission has been actioned, i.e. reviewed or canceled.

Build from Source

You can also get the source for for the SDK on GitHub, with support for Swift Package Manager, CocoaPods, and Carthage. See GitHub, Facebook iOS SDK Source.

First create a local copy of the SDK by cloning it your chosen location:

git clone git://github.com/facebook/facebook-ios-sdk.git

Swift Package Manager

You can use a local checkout of the SDK via Swift Package by adding a new Swift Package with the URL:

file:///User/<your unix name>/path-to-checkout/facebook-ios-sdk

To use in your code simply import the kits your want. For instance:

import FacebookCore
import FacebookLogin
import FacebookShare
// Either:
@import FBSDKCoreKit;
@import FBSDKLoginKit;
@import FBSDKShareKit;

// Or:
#import <FBSDKCoreKit.h>
#import <FBSDKLoginKit.h>
#import <FBSDKShareKit.h>

CocoaPods

You can also use a local checkout of the SDK via CocoaPods by adding the following to your Podfile.

pod 'FBSDKCoreKit/Swift', :path => '/Users/<your-unix-name>/<path-to-checkout>/facebook-ios-sdk'
pod 'FBSDKLoginKit/Swift', :path => '/Users/<your-unix-name>/<path-to-checkout>/facebook-ios-sdk'
pod 'FBSDKShareKit/Swift', :path => '/Users/<your-unix-name>/<path-to-checkout>/facebook-ios-sdk'
pod 'FBSDKCoreKit', :path => '/Users/<your-unix-name>/<path-to-checkout>/facebook-ios-sdk'
pod 'FBSDKLoginKit', :path => '/Users/<your-unix-name>/<path-to-checkout>/facebook-ios-sdk'
pod 'FBSDKShareKit', :path => '/Users/<your-unix-name>/<path-to-checkout>/facebook-ios-sdk'

To use in your code simply import the kits your want. For instance:

import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit
// Either:
@import FBSDKCoreKit;
@import FBSDKLoginKit;
@import FBSDKShareKit;

// Or:
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>

Carthage

You can also use a local checkout of the SDK via Carthage by adding the following to your Cartfile.

git "file:///Users/<your-unix-name>/<path-to-checkout>/facebook-ios-sdk" "master"

Swift

v4.1 of the SDK supports modules natively so no bridging headers are required. Simply import the appropriate kit module in your .swift files, such as

import FBSDKCoreKit
import FBSDKShareKit
import FBSDKLoginKit

Or if you're using Swift Package Manager

import FacebookCore
import FacebookLogin
import FacebookShare

Advanced App Configuration

Optionally, if you want all the SDK classes to work out of the box you can also add the -ObjC linker flag to your project.

If you to do this you increase the size of your app's executable since the due to additional SDK object code loads into your application.

You can learn more about the trade offs, about the -ObjC flag, and how to set it in our iOS Troubleshooting, Unrecognized Selector Error.

Troubleshooting

Tips on common scenarios, workarounds for major known issues.

FAQs and Troubleshooting