可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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
Based on what I read elsewhere
- I have already cleaned the build and re-installed Xcode.
- 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).
- I have double checked the plist and the framework files FB lists in the instructions, but nothing has seemed missing.
I'm stumped.
回答1:
FBSDKCoreKit can't be built because of "include of non-modular header inside framework module" error in FBSDKAppLinkResolver.h header file: in #import
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:
- Create in Bolts.framework file module map: Modules/module.modulemap (like in FBSDKCoreKit.framework)
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...
回答2:
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.
回答3:
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
回答4:
For Objective-C I used Paul Lehn answer from: https://developers.facebook.com/bugs/362995353893156/
- 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)
- "Allow Non-modular Includes in Framework modules" setting to YES in Build settings
- 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
回答5:
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:
- Remove all module maps as Chris said.
- 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.
回答6:
Remove Module Directory From FacebookCoreKit.framwork.
回答7:
If you are having issue with 'FBSDKCoreKit' You can try below solutions:
Goto Build Setting and search for "allow non-modular" and Set
"Allow Non-modular Includes in Framework modules" flag to YES
Go to Document/FacebookSDK folder
then goto FBSDKCoreKit.framework
In this folder Remove Modules folder. Then add the FacebookSDK library in your project.
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"
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
This will fix your problem
回答8:
Got this issue too, you need to set
Enable Modules (C and Objective-C)
to NO.
回答9:
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.
回答10:
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.
回答11:
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:
In Build Settings under Apple LLVM Modules:
- Set Allow Non-modular Includes in Framework modules" setting to NO
- Enable Modules (C and Objective C) to NO.
Create a bridging header to include the Facebook SDK headers
- Link bridging header in Build Settings : Swift Compiler - Code Generation.
- Import FBSDKCoreKit into your App Delegate file and implement the core Facebook SDK requirements as per the FB documentation
回答12:
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.
回答13:
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).
回答14:
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
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!
回答15:
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
回答16:
Make sure you've also imported the Bolts framework, this worked for me.