Unknown class FBSDKLoginButton in Interface Builder file

I have a very difficult build problem with my new project. I am trying to integrate the Facebook iOS SDK, but for some reason I am getting some weird errors. You try to use FBSDKLoginKit to display FBSDKLoginButton in the storyboard view.

The first hint of an error is the β€œerror” when trying #import <FBSDKLoginKit/FBSDKLoginKit.h> (however, it only appears as an error in the editor, it still compiles):

"Failed to create FBSDKLoginKit module."

Strange, this β€œerror” went away after messing around with some build settings related to the module, even when I returned them to their original values.

It's also interesting if I explicitly reference the FBSDKLoginButton class from my view controller (for example, add a button programmatically), then creating a storyboard based instance works fine. Therefore, I suppose that this must be a problem with the linker or something, but I, admittedly, am not a professional in this matter.

None of the documentation in the Facebook SDK mentions this issue, which I can find is strange because, as I said, this is a completely new clean project.

+6
source share
2 answers

My bad one, the documentation mentions this , and suggests solving it, as I already found out, referring to the FBSDKLoginButton class in application didFinishLaunchingWithOptions: (Honestly, it doesn't matter where you refer to it, so where it’s convenient is best for me.)

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [FBSDKLoginButton class]; ... return YES; } 
+12
source

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 } 
+1
source

Source: https://habr.com/ru/post/987445/


All Articles