Search code examples
iosfacebookautomatic-ref-countingstatic-libraries

Incomplete protocols warning when using a protocol define in a static lib (facebook-ios-sdk)


I am trying to integrate the facebook ios SDK within my project which use ARC. As suggested in the facebook developer documentation it is recommended to build the facebook SDK as a static lib for this type of integration. I run the script provided to build the static lib and then added to my project by:

  1. directly dragging all the contents of output directory lib: lib\facebook-ios-sdk (which contains the lib and associated headers)

  2. in the Link Binaries with libraries / build phases section of my target project i have added my static lib explicitly

I have a class that is implementing all methods of FBSessionDelegate. However I have a couple of warning for each method of this delegate that are not seen as implemented by the compilo :

Semantic Issue
Method in protocol not implemented
Required for direct or indirect protocol 'FBSessionDelegate'

The methods concerned are those ones:

- (void)fbDidLogin;
- (void)fbDidNotLogin:(BOOL)cancelled;
- (void)fbDidExtendToken:(NSString*)accessToken
               expiresAt:(NSDate*)expiresAt;
- (void)fbDidLogout;
- (void)fbSessionInvalidated;

I really don't understand why the compilo is giving me those warning :-\ Does anyone has an idea why we have such a behavior? I have seen in this blog that they add the whole facebook-ios-sdk to the project but ideally i just want to add the lib and not the full project.

Any clarification / help would be greatly appreciated!

[EDIT] The issue I am mentioning can easily be reproduce by simply following the turorial of this page to test the connection with an app on facbook here. In the following i have implemented the fDidLogin method and still I have a warning for this method...

My header file look like:

#import <UIKit/UIKit.h>

#import "FBConnect.h"

@class SCLViewController;

@interface SCLAppDelegate : UIResponder <UIApplicationDelegate, FBSessionDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) SCLViewController *viewController;

@property (strong, nonatomic) Facebook *facebook;

@end

and the .m:

#import "SCLAppDelegate.h"

#import "SCLViewController.h"

@implementation SCLAppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;
@synthesize facebook = _facebook;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
     _facebook = [[Facebook alloc] initWithAppId:@"MY-APP-ID" andDelegate:self];
            
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] 
        && [defaults objectForKey:@"FBExpirationDateKey"]) {
        _facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        _facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }
   
    
    if (![_facebook isSessionValid]) {
        [_facebook authorize:nil];
    }
   
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[SCLViewController alloc] initWithNibName:@"SCLViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    
    
    return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [_facebook handleOpenURL:url]; 
}


- (void)fbDidLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[_facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[_facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];
    
}

@end

Solution

  • in your code you specify that your interface is implementing the FBsesionDelegate protocol but you have not actually created any implementation for it by creating the protocol method callbacks. if you do not need them , just remove the implementation declaration or add empty methods. in any case those warning will not affect compilation or create any problem in your code except if you actually want some session callbacks.