Take the 2-minute tour ×

I have an app that currently supports posting to Facebook through the feed dialog using the old Facebook SDK for iOS.

After updating to the Facebook SDK 3.1 for iOS, it seems that I can either:

  1. use the old style API (Facebook.h, instantiate a Facebook, call dialog:...)
  2. or use the new style API (FacebookSDK.h, use shared FBSession, native dialogs)

The different header files collide and seem completely incompatible.

Can I do both? If so, then how?

share|improve this question

5 Answers 5

Just include Facebook.h instead. To do this first, Copy the DeprecatedHeaders folder into your Frameworks project. The DeprecatedHeaders are found under ~/Documents/FacebookSDK/FacebookSDK.frameworks/Versions/A/. When you copy it over do not copy the items into your project, so they stay copied as a reference.

Next, in your code where you have:

#import <FacebookSDK/FacebookSDK.h>

Replace with this:

#import "Facebook.h"

You may get an error, in which case close and reopen the project.

Next you want to declare a Facebook object and set the session or clear it whenever your Session is open or closed.

Take as an example, the sample: https://github.com/fbsamples/ios-3.1-howtos/tree/master/ShareNativeDialogsHowTo that is documented here, https://developers.facebook.com/docs/howtos/share-native-dialogs-ios-sdk/

You could make the following changes to that sample to fallback to the feed dialog instead of falling back to a view controller with a share UI. In ViewController.m you would make these changes after including the Facebook header:

@property (unsafe_unretained, nonatomic) IBOutlet UIButton *publishButton;
@property (nonatomic, retain) Facebook *facebook;

@synthesize authButton;
@synthesize facebook = _facebook;

- (void)sessionStateChanged:(NSNotification*)notification {
    if (FBSession.activeSession.isOpen) {
        self.publishButton.hidden = NO;
        [self.authButton setTitle:@"Logout" forState:UIControlStateNormal];
        if (nil == self.facebook) {
            self.facebook = [[Facebook alloc]
            // Store the Facebook session information
            self.facebook.accessToken = FBSession.activeSession.accessToken;
            self.facebook.expirationDate = FBSession.activeSession.expirationDate;
    } else {
        self.publishButton.hidden = YES;
        [self.authButton setTitle:@"Login" forState:UIControlStateNormal];
        self.facebook = nil;

- (void) publishUsingFeedDialog {
    // Put together the dialog parameters
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:

    // Invoke the dialog
    [self.facebook dialog:@"feed" andParams:params andDelegate:nil];

- (IBAction)publishButtonAction:(id)sender {
    BOOL displayedNativeDialog =

    if (!displayedNativeDialog) {
        /*ShareViewController *viewController =
        [[ShareViewController alloc] initWithNibName:@"ShareViewController"
        [self presentViewController:viewController
        [self publishUsingFeedDialog];
share|improve this answer
It shows duplicate implementation errors for several objects. –  Bala May 9 '13 at 10:04
You should move to the newer 3.5 SDK and take a look at this tutorial for how to use the feed dialog - developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk –  C Abernathy May 9 '13 at 17:30

I think you will get an "duplicate error" if you use both. I know it sucks.

Ive been messing with the duplicate error for days now. Please let me know if you got there.

share|improve this answer

You'll probably have to abstract out a common interface and implement it twice in separate source files (so the compiler never sees Facebook.h and FacebookSDK.h in the same file).

share|improve this answer
The conflicts are at the duplicate Objective-C interface definition level. These are not resolved through importing the files separately. The ObjC runtime will not allow it. –  John Cromartie Oct 4 '12 at 21:34
Where you able to solve the duplicate error? –  estemendoza Jan 15 '13 at 22:47

It's impossible, you should use Graph API https://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/ instead of Feed Dialog :(

share|improve this answer

Try to import


instead of


it will solve the duplicate error..

share|improve this answer

Your Answer


