Cannot find module FBSDKCoreKit Cocoapods

核能气质少年 提交于 2019-12-21 18:20:01

问题


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

  1. Removing the Bridging Header. Facebook SDK doesn't need them anymore after version 4.1
  2. Adding all of the .frameworks to the Projects Build Phases -> Link Binary With Libraries
  3. Selecting each framework and building it. You can do this by selecting your project name next to the run arrow.
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!