No such module 'FacebookCore' in swift 5
Asked Answered
H

3

8

I am doing my own test app as part of my learning process in iOS development (using swift 5 on Xcode 11.0). I want to add login with Facebook on my login page but I keep getting No such module 'FacebookCore' when importing the library.

enter image description here

I followed the instructions on developer.facebook and tried to implement the SDK using cocoaPods and here is my Podfile

 # Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'TestApp' do

  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TestApp
  pod 'FBSDKCoreKit'
  pod 'FBSDKLoginKit'

  target 'TestAppTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'TestAppUITests' do
    # Pods for testing
  end

end

After executing pod install and adding the data in my info.plist as instructed by Facebook, I can clearly see that the framework has been linked in the Link Binary With Libraries section

enter image description here

But still, I can't seem to import FacebookCore nor FacebookLogin.

PS: I tried several solutions like:

1- Running the .xcworkspace instead of .xcodeproj

2- Building the project even with the error being displayed (some said it would go away)

But none of them worked.

I suspect that the problem is in my Framework search path but why would it be wrong in the first place? so I may be wrong, here's a screenshot to my search path anyway:

enter image description here

Haemostatic answered 31/1, 2020 at 14:26 Comment(5)
Steps undertaken look fine. After pod install make sure you open the xcworkspace and not the xcodeproj file. Are you sure you created an iOS application and not a macOS application.Consternate
what you open ? workspace or project ?Colchicine
The error remains when I try to run the app from the .xcworkspace file. And yes I'm positive it's an iOS and not a macOS app.Haemostatic
@jawadAli I tried both but I'm having the same error on bothHaemostatic
okay let me check ... use .workspaceColchicine
H
15

So it turned out that I have to import FBSDKCoreKit instead of FacebookCore which was not mentioned in facebook's documentation. And it should be imported strictly using the .xcworkspace file which was also not mentioned in the documentation.

Haemostatic answered 31/1, 2020 at 15:0 Comment(3)
Still the solution in 2022.Mano
"imported strictly using the .xcworkspace file" how do I do that?Magee
Close the project and go to your project directory and open the .xcworkspace file (the white icon) and from there just add import FBSDKCoreKit to your class and it should work.Haemostatic
S
7

Use FBSDKCoreKit instead of FacebookCore

This are the correct pods

  pod 'FBSDKCoreKit'
  pod 'FBSDKLoginKit'

and your imports should be

import FBSDKCoreKit
import FBSDKLoginKit

in previous version there was FacebookCoore as wrapper for the FBSDKCoreKit classes. It looks like Facebook has removed this since v5.x.

Scientism answered 12/5, 2020 at 12:18 Comment(0)
N
-1

The following should be your entries in Podfile

  pod 'FacebookCore'
  pod 'FacebookLogin'

and your imports should be

import FacebookCore
import FacebookLogin
Nickelodeon answered 31/1, 2020 at 15:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.