Facebook iOS8 SDK build module error for FBSDKCoreKit
Asked Answered
E

16

42

I am trying to add the Facebook SDK to my iOS 8 Objective-C app in Xcode. I did the install according to the FB-dev instructions. However, I get a "Could not build module 'FBSDKCoreKit'" error when I add the header to my AppDelegate.m file.

#import "AppDelegate.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>

Based on what I read elsewhere

  1. I have already cleaned the build and re-installed Xcode.
  2. I also re-installed the Facebook SDK installer and tried to add it to a blank project (in case there was something corrupt with my app).
  3. I have double checked the plist and the framework files FB lists in the instructions, but nothing has seemed missing.

I'm stumped.

Euphrosyne answered 3/4, 2015 at 15:45 Comment(1)
None of these answers worked for me. Mine was a collision with an old Bolts.framework. https://mcmap.net/q/128666/-facebook-ios8-sdk-build-module-error-for-fbsdkcorekitYell
E
47

FBSDKCoreKit can't be built because of "include of non-modular header inside framework module" error in FBSDKAppLinkResolver.h header file: in #import <Bolts/BFAppLinkResolving.h> line.

The solution from Swift compiler error: "non-modular header inside framework module" (switching CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES) did't help me.

My solution:

  1. Create in Bolts.framework file module map: Modules/module.modulemap (like in FBSDKCoreKit.framework)
  2. Put such code inside

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

Interesting fact is that in FBSDKCoreKit such scheme is realized by Facebook, why didn't they apply it into Bolts...

Edition answered 5/4, 2015 at 12:56 Comment(4)
Yeah you just saved me an hour of head scratching - thanks :DSmoking
this is better than changing the build settingDelightful
what do you mean 'create in bolts framework' - do you mean add a header to the bolts framework.framework ?Jewry
Can anyone please explain how to do this step. "Create in Bolts.framework file module map: Modules/module.modulemap". Would be very grateful.Marie
J
41

Not sure if it has side effects but setting the "Allow Non-modular Includes in Framework modules" setting to YES in Build settings solved the problem for me. Hope it works for you too.

Jarredjarrell answered 3/4, 2015 at 19:16 Comment(3)
I've tried this, but still getting the "Include of non-modular header" error. Was that the only thing you changed?Disharmony
Yes, but i'm not sure why it worked. I tried one of the sample projects and in works with the setting set to NO.Jarredjarrell
@vladiMilk I am using pod to integrate fb and all suggested solutions are not working for me, please help me as soon as possible.Simplehearted
T
14

Just doing the following let me to build the app successfully.

In Build settings Set "Allow Non-modular Includes in Framework modules" flag to YES

And I didn't want to Set "Enable Modules" (c and Objective-C) to NO

enter image description here

Town answered 21/4, 2015 at 12:14 Comment(4)
I only need to do : Set "Allow Non-modular Includes in Framework modules" flag to YES to work this properlyShivaree
I am facing the problem in another libraries when i set enable modules = NO. and Facebook problem fixed but getting error in another libraries . please help meMinotaur
@Randika i fixed other library problem using adding some framework in build. but again getting error that #import <FBSDKCoreKit/FBSDKCoreKit.h> is not found. i am confuse what i am missing ,please help meMinotaur
I had to do this on the Pods project for it to work. It didn't work if I just changed one or two of the pods that were complaining.Danonorwegian
H
11

For Objective-C I used Paul Lehn answer from: https://developers.facebook.com/bugs/362995353893156/

  1. Add the -ObjC flag to your project's Other Linker Flags build setting. (if you don't want add to project configs, for initialise buttons classes)
  2. "Allow Non-modular Includes in Framework modules" setting to YES in Build settings
  3. Set "Enable Modules" (c and Objective-C) to No

(also don't forget add frameworks, for me it was: "AdressBook" "QuartzCore" "CoreLocation" "CoreGraphics" and if still not added, also "UIKit" "Foundation" "CoreData")

and its finally worked for me

all this used for linked FBSDK in custom folder in my project folder not from ~/Documents/FacebookSDK

Hopfinger answered 6/4, 2015 at 17:46 Comment(0)
S
11

Remove Module Directory From FacebookCoreKit.framwork.

enter image description here

Slotter answered 16/4, 2015 at 11:35 Comment(0)
S
9

From Chris Pan (Facebook Team): https://developers.facebook.com/bugs/362995353893156/

The 4.0.1 release added module maps (which should have obviated the need for bridging headers) but it looks like that may have caused some other compatibility issues. We're working on a proper fix but another workaround is to remove the module maps manually from each of the FBSDK*Kit.framework bundles; e.g., rm -r ~/Documents/FacebookSDK/FBSDKCoreKit.framework/Modules/ (and repeat for FBSDKLoginKit and FBSDKShareKit)

As far as I know, we have 2 options to deal with this problem:

  1. Remove all module maps as Chris said.
  2. Add a temporary (unofficial) missing module map file in Bolts.framework folder (in FacebookSDK folder). You should check if this folder is missing or not.
Scalise answered 8/4, 2015 at 7:10 Comment(3)
This problem has been fixed in SDK 4.1!Scalise
@TrinhNgocThuyen are you sure it is fixed? I am having this issue with 4.6Snell
@Snell I'm having the same issue with 4.6 as well... none of the answers here seems to fix the problem for me. Did you make it work somehow?Suzerainty
H
8

If you are having issue with 'FBSDKCoreKit' You can try below solutions:

  1. Goto Build Setting and search for "allow non-modular" and Set

    "Allow Non-modular Includes in Framework modules" flag to YES

enter image description here

  1. Go to Document/FacebookSDK folder

    then goto FBSDKCoreKit.framework

    In this folder Remove Modules folder. Then add the FacebookSDK library in your project.

  2. Set the Framework search path to "~/Documents/FacebookSDK"

    Steps to find Framework search Path

    Goto build setting of the project and search for "framework search path".

    Then add "~/Documents/FacebookSDK"

enter image description here

Edit:

please open the Framework search path in Facebook app and copy paste all the paths mentioned over there in your application.Similar to the path i have attached in below screen shots

enter image description here

This will fix your problem

Homogenize answered 10/7, 2015 at 13:51 Comment(2)
Did all of that - still no luck. I only face this problem when using the api with an swift project. the facebook sample app works fine...Satiable
@ArEsiiX i have updated my answer ,i hope this works for you.Homogenize
S
3

Got this issue too, you need to set

Enable Modules (C and Objective-C)

to NO.

Steen answered 4/4, 2015 at 19:17 Comment(0)
I
1

I have faced the same problem. The issue was that my project directory contained space in the name "Application Demo". That's why whenever I dragg the Facebook frameworks then it added space in Framework Search Paths in settings. Remove this space resolved the issue.

Ingot answered 7/4, 2015 at 10:55 Comment(1)
Wow, Happen the same thing to me. is there any explanation for this ?Irrelevancy
Y
1

TL;DR Remove your Bolts.framework reference in your project.

None of these or any of the other answers worked for me (in my case). For my project we were switching from an older Facebook sdk and we had a Bolts.framework.

Reading the documentation

The SDK automatically loads its framework and resource dependencies.

As such I think there is a collision going on. There was the Bolts.framework I had from before and then the new one that came when I downloaded the new FacebookSDK bundle (4.7 in this case).

Removing my Bolts.framework fixes the problem (be sure to clean before rebuilding).

Yell answered 13/10, 2015 at 23:35 Comment(0)
F
1

I got the same problem, I was using the newest Facebook SDK (FacebookSDKs-iOS-20160316) on Xcode 6.4, it consistently gives me this error whenever I put the following code in my AppDelegate.m file: #import <FBSDKCoreKit/FBSDKCoreKit.h>

When I switched to Xcode 7.2, problem solved, the error is gone. Guess this maybe the version compatible issue

If you are facing the same issue with me, you can have a try to use Xcode 7.2 to build it. Problem is Xcod 6.4 may never be able to used as long as you keep the Facebook sdk in your project.

Hope this helps!

Flin answered 24/3, 2016 at 19:53 Comment(0)
I
0

You're probably importing the "Samples" folder that comes with Facebook's SDK into your project. Remove the references to those files from your project and it should work. No need to change flags on your build settings.

Ivanovo answered 6/4, 2015 at 16:39 Comment(0)
S
0

I should direct you to this current open issue assigned to Facebook: https://developers.facebook.com/bugs/362995353893156/. None of the answers here helped me, so I assume we just sit ducks:

As at time of writing, a message from Facebooks Chris Pan:

"The 4.0.1 release added module maps (which should have obviated the need for bridging headers) but it looks like that may have caused some other compatibility issues. We're working on a proper fix but another workaround is to remove the module maps manually from each of the FBSDK*Kit.framework bundles; e.g., rm -r ~/Documents/FacebookSDK/FBSDKCoreKit.framework/Modules/ (and repeat for FBSDKLoginKit and FBSDKShareKit)"

Kosala Ubayasekara got it to work, but since this is an open issue you might want to simply wait until an official fix is clear:

  1. In Build Settings under Apple LLVM Modules:

    1. Set Allow Non-modular Includes in Framework modules" setting to NO
    2. Enable Modules (C and Objective C) to NO.
  2. Create a bridging header to include the Facebook SDK headers

  3. Link bridging header in Build Settings : Swift Compiler - Code Generation.
  4. Import FBSDKCoreKit into your App Delegate file and implement the core Facebook SDK requirements as per the FB documentation
Sherr answered 8/4, 2015 at 4:27 Comment(1)
@Joker I included the answer from Facebook.Sherr
R
0

Same issue was with me. ... Non of the above solution works for me.. I set . modules, flags and other things also... but nothing help to it.

But for me this issue is solved by

MOVE your framework folder AFTER or WITHIN the folder where .pch file is located at.

When my framework folder @ myapp/{frameworkFolder}/fbframeworks.
It was showing issues.

I move it to myapp/myapp/modal/{fbframework}/. Then this issue was solved. (my .pch file is located at myapp/myapp.)

May be the same can help to anyone having same issue.

Radically answered 28/5, 2015 at 13:14 Comment(0)
R
0

For those who came here and made the same rookie mistake like I did. Maybe I can save you some time. I work on an old project which largely consists of Objective-C code. We try to implement new stuff in Swift.

This was what i tried in my Swift code

import FBSDKCoreKit

class SomeClass {

  func doSomething {
    FBSDKAppEvents.logEvent("Some Event")
  }
}

But the compiler complained that it could not compile the module, etc.

How I solved it

  • Remove the import FBSDKCoreKit from my Swift code.
  • Edited our Bridging-Header.h and imported FBSDKCoreKit there: #import <FBSDKCoreKit/FBSDKCoreKit.h>
Rockfish answered 23/2, 2017 at 14:9 Comment(0)
G
0

Make sure you've also imported the Bolts framework, this worked for me.

Greenland answered 26/4, 2017 at 23:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.