Jacob Ruth
Jacob Ruth

Reputation: 181

Cannot find module FBSDKCoreKit Cocoapods

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.

Upvotes: 7

Views: 12735

Answers (7)

thaonguyen
thaonguyen

Reputation: 21

You can try : pod 'FBSDKCoreKit/Swift'

Upvotes: 0

Osama Remlawi
Osama Remlawi

Reputation: 2990

Very simple solution, if you are using Apple Swift Packages:

  1. Go to Navigator pane and select the project

  2. Then make sure you choose project name under "Project" not under "Targets"

  3. Then select Package Dependencies tab

  4. You will find the Facebook package there, double click on it enter image description here

  5. Change version to 9.0.0 and click "Done"

  6. Rebuild, and it should be corrected.

Note that you may need this url to add Facebook SDK as Apple Swift Packages rather than Cocoapods.

Upvotes: 0

Sazzad Hissain Khan
Sazzad Hissain Khan

Reputation: 40156

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

Upvotes: 1

footyapps27
footyapps27

Reputation: 4042

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.

enter image description here

Upvotes: 2

Lipu Hossain
Lipu Hossain

Reputation: 79

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

Upvotes: -2

Jacob Ruth
Jacob Ruth

Reputation: 181

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.

Upvotes: 0

Catalina T.
Catalina T.

Reputation: 3494

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) enter image description here

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.

Upvotes: 0

Related Questions