Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SDK 4.0.1 Swift Errors xcode 6.2 iOS 8.2

Here in this change-log(facebook change-log) it is stated that there is no need for objective-c bridging headers for swift.

But when I import FBSDKCoreKit in AppDelegate.swift these errors occur:

FBSDKAppLinkResolver.h

/Users/[username]/Documents/FacebookSDK/FBSDKCoreKit.framework/Headers/FBSDKAppLinkResolver.h:21:9: Include of non-modular header inside framework module 'FBSDKCoreKit.FBSDKAppLinkResolver'

AppDelegate.swift

/Users/ashrafkholeif/Projects/xcode/TabbedApplicationTemplate/TabbedApplicationTemplate/TabbedApplicationTemplate/AppDelegate.swift:10:8: Could not build Objective-C module 'FBSDKCoreKit'

edit: I even set the allow non-modular header inside framework modules to YES.

like image 226
Ashraf Kholeif Avatar asked Apr 04 '15 13:04

Ashraf Kholeif


4 Answers

I had the exact same issue, the solution suggested on https://stackoverflow.com/a/29457503/425682 for an Objective-C project worked straight away on my Swift project:

Write a new file in the Facebook SDK folder under Bolts.framework/Modules/module.modulemap with the following content:

framework module Bolts {
umbrella header "Bolts.h"

export *
module * { export * }


explicit module BFAppLinkResolver {
    header "BFAppLinkResolver.h"
    link "BFAppLinkResolver"
    export *
}}

This works without bridging headers (not needed anymore in version 4.0.1 of the SDK as mentioned by the OP), and without changes to the build settings.

EDIT: this bug is now fixed as of version 4.1 of the Facebook SDK, the library works without having to do any change.

like image 168
ahelix Avatar answered Oct 09 '22 21:10

ahelix


This is a bug and Facebook is currently "assigning this to the appropriate team".

To get updates to this issue follow this link:

https://developers.facebook.com/bugs/362995353893156/

and hit subscribe.

Hopefully it doesn't take them too long to fix.

Also here is a related question recently posted on SO:

issue using FBSDK in swift iOS application

And some people have found success using the answers on this link (none have worked for me):

Facebook iOS8 SDK build module error for FBSDKCoreKit

like image 33
Paul Lehn Avatar answered Oct 09 '22 22:10

Paul Lehn


The fix that worked for me:

rm -r ~/Documents/FacebookSDK/FBSDKCoreKit.framework/Modules/

Repeat with other frameworks.

Source: https://developers.facebook.com/docs/ios/troubleshooting#xcode_link

like image 2
charlax Avatar answered Oct 09 '22 23:10

charlax


Create a new header file and import any objective-c code you are using, something like this..

#ifndef RJv1_RJBridge_h
#define RJv1_RJBridge_h
#import "NSMutableString+Obfuscated.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#endif

Then go to your Build Settings, look for Install Objective-C Compability Header, and make sure is set to Yes, then add a relative path to your header file in the field Objective-C Bridging Header.

Hope it works!

like image 1
Ernesto Cambustón Avatar answered Oct 09 '22 23:10

Ernesto Cambustón