8

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?

Community
  • 1
  • 1
wllychng
  • 242
  • 1
  • 4
  • 14

6 Answers6

19

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

Community
  • 1
  • 1
blwinters
  • 1,911
  • 19
  • 40
7

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.

Danoram
  • 8,132
  • 12
  • 51
  • 71
  • 1
    This actually worked for me. Got build errors when opening the workspace for my project but manually selecting product build fixes the issue. – Fraggle Nov 24 '16 at 17:05
6

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
Manish Singh
  • 310
  • 1
  • 5
  • 19
2

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
William Hu
  • 15,423
  • 11
  • 100
  • 121
0

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'
tbilopavlovic
  • 1,096
  • 7
  • 13
  • I tried updating my pod commands with the ones you provided, did another pod install, but XCode still does not recognize the import of the Facebook modules. Sorry, I'm not that good with building of developer tools, so I don't really know how building and linking works (except the basics). Looking through the link you provided, theres mention of use_frameworks! for swift dependencies, but where do you set this and what does it do? Is this a build option in XCode? – wllychng May 10 '15 at 23:06
  • I am still having the same issue as well (even after adding the lines to the pod file). – Nate Uni May 12 '15 at 12:45
0

You should use

PROJECT.xcworkspace

file after editing Podfile and executing

pod install

command,

code_ada
  • 874
  • 12
  • 25