wllychng
wllychng

Reputation: 242

Facebook iOS SDK v 4.1.0 in Swift with Cocoapods: cannot import modules

I tried to update my Swift project to Facebook SDK v 4.1.0 today (FBSDKCoreKit and FBSDKLoginKit), but it doesn't seem to be working. I cannot import the modules as they are not found.

I basically removed the line

pod 'Facebook-iOS-SDK'

and added the lines

pod 'FBSDKCoreKit'

pod 'FBSDKLoginKit'

and then did a pod install. The Facebook doc says the new SDK supports direct imports, so I tried

import FBSDKCoreKit

in one of my project files, but it says No such module 'FBSDKCoreKit'

I looked around and found the following links which talk about bug with building module, and the Facebook bug report and changelog:

issue using FBSDK in swift iOS application

https://developers.facebook.com/bugs/362995353893156/

https://developers.facebook.com/docs/ios/change-log-4.x

However, it seems to claim that the issue has been fixed in v 4.1.0 (seems to be the main reason for the update), so this isn't the problem in my case? Anyone have any information about this / have a solution?

Upvotes: 8

Views: 10357

Answers (6)

code_ada
code_ada

Reputation: 884

You should use

PROJECT.xcworkspace

file after editing Podfile and executing

pod install

command,

Upvotes: 0

Manish Singh
Manish Singh

Reputation: 310

I know its an old post but thought to update the podfile for someone who would face the same issue i was facing.

You can use this with iOS 9 and swift,once you run pod install you are good to go for

import FBSDKLoginKit
import FBSDKShareKit
import FBSDKCoreKit

in swift files

-----Podfile------

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!


target 'FBIntegration' do

pod 'Bolts'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'

end

Upvotes: 6

Daniel Oram
Daniel Oram

Reputation: 8411

I just ran into this problem of not being able to import the FBSDK directly into my files after I installed the sdk using cocoapods..

But after performing a build, the import statements worked fine!

For some people experiencing this problem it might be as simple as that.

Upvotes: 7

William Hu
William Hu

Reputation: 16141

If you have already added a bridging_header file you also can just add

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>

into it. Then import directly

import FBSDKLoginKit

Upvotes: 2

blwinters
blwinters

Reputation: 2191

Try adding use_frameworks! to the top of your podfile, as suggested by this answer. Here's a blogpost that explains the issue.

Upvotes: 19

tbilopavlovic
tbilopavlovic

Reputation: 1098

Check here. Try with this in podfile:

pod 'FBSDKCoreKit', :git => 'https://github.com/facebook/facebook-ios-sdk.git', :branch => 'dev'
pod 'FBSDKLoginKit', :git => 'https://github.com/facebook/facebook-ios-sdk.git', :branch => 'dev'

Upvotes: 0

Related Questions