问题
I'm trying to integrate facebook into my app using CocoaPods, using the use_frameworks! tag, and according to facebook's instructions here, also included the pod bolts. When I try use import FBSDKCoreKit
in my appdelegate, I get a no such module 'FBSDKCoreKit error. I've included my podfile below:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.2'
use_frameworks!
pod 'Bolts'
pod 'Alamofire', '~> 3.0'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
Additionally, in my Pods folder, there is a question mark next to Bolts, FBSDKCoreKit, and FBSDKSharekit, but not one next to alamofire, which I had been using previously. In the Frameworks folder in my Pods project, FBSDKCoreKit and Bolts are listed there, but are both red. Any ideas? I've tried cleaning my project, and reinstalling and updating the pods.
回答1:
For people moving from Carthage
to Cocoapods
make sure to remove the Carthage references of the FBSDKCoreKit
from the Link Binary With Libraries
under Build Phases
option.
回答2:
Seems that the facebook pods are Objective-C and they need a special way of importing in a swift project.
This is how I got it to work:
Create a bridging header in your project, if you dont have one(I created a new header file called Bridging-Header.h
and set it as a bridging header in the project settings, like in the screenshot)
Then in this file import the facebook modules. Here's how my file looks like:
#ifndef Bridging_Header_h
#define Bridging_Header_h
@import FBSDKCoreKit;
@import FBSDKLoginKit;
#endif /* Bridging_Header_h */
Let me know if this workout for you or you need more help.
回答3:
I fixed this by
- Removing the Bridging Header. Facebook SDK doesn't need them anymore after version 4.1
- Adding all of the .frameworks to the Projects Build Phases -> Link Binary With Libraries
- Selecting each framework and building it. You can do this by selecting your project name next to the run arrow.
- Cleaning the project and restarting my computer.
回答4:
Please try below steps,
- Explicitly mention the versions i.e.
pod 'FBSDKCoreKit', '~>5.8.0'
pod 'FBSDKShareKit', '~>5.8.0'
pod 'FBSDKLoginKit', '~>5.8.0'
- Update pod repo using
sudo pod repo update
- Update pod using
pod update
回答5:
first add in pod file
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
this is facebook swift library,after that before using FBSDKCoreKit,just use FacebookCore then import FBSDKCoreKit
来源:https://stackoverflow.com/questions/35527672/cannot-find-module-fbsdkcorekit-cocoapods