Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown class FBSDKLoginButton in Interface Builder file

I am experiencing a very frustrating build issue with my brand new project. I am trying to integrate Facebook iOS SDK, but for some reason I am getting some bizarre errors. When trying to use FBSDKLoginKit to display an FBSDKLoginButton on a storyboard view.

The first hint something is wrong is this "error" when I attempt to #import <FBSDKLoginKit/FBSDKLoginKit.h> (however it only appears as an error in the editor; it still compiles fine):

"Could not build module FBSDKLoginKit."

Strangely, this "error" went away after fiddling with some of the module-related build settings, even when I set them back to their original values.

Also interestingly, if I explicitly reference the FBSDKLoginButton class from my view controller (for example add the button programmatically), then storyboard-based instantiation works fine. So I'm guessing this must be some linker issue or something, but I'm admittedly not a pro at that stuff.

None of the Facebook SDK documentation mentions this issue that I can find, which is bizarre because like I said this is a brand new clean project.

like image 258
devios1 Avatar asked May 18 '15 19:05

devios1


2 Answers

My bad, the documentation does mention this, and suggests solving it much as I already figured out, by referencing the FBSDKLoginButton class in application didFinishLaunchingWithOptions:. (Frankly it doesn't matter where you reference it, so wherever feels most comfortable. For me, the view controller makes more sense.)

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [FBSDKLoginButton class];
    ...
    return YES;
}
like image 105
devios1 Avatar answered Sep 21 '22 02:09

devios1


For Swift use FBSDKLoginButton.superclass()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    FBSDKLoginButton.superclass()

    return true
}
like image 39
johnny Avatar answered Sep 18 '22 02:09

johnny