Can't import dependency installed with Cocoapods

后端 未结 11 1150
醉梦人生
醉梦人生 2021-02-07 11:16

I\'ve installed FBSDK with Cocoapods but can\'t import it in my AppDelegate.swift file for some reason. The FBSDK kit appears in my Xcode project so I feel like it should be wor

相关标签:
11条回答
  • 2021-02-07 11:49

    Are you opening the .xcodeproj or the .xcworkspace? Make sure it is the workspace whenever you install a cocoapod

    0 讨论(0)
  • 2021-02-07 11:51

    First Clean your project directory. And add $(inherited) in framework search path in Build settings.

    0 讨论(0)
  • 2021-02-07 11:53

    Start by cleaning your project using Command + Shift + K then close the project and delete the pods folder and the pod.lock file and your .xcworkspace file. Then run pod install and see if that fixes the issue.

    0 讨论(0)
  • 2021-02-07 12:01

    In my case, it was correctly installed but I realized the pod is Objective-C and couldn't import it on a Swift file. I had to create a bridging header to make it work.

    Refer to this stackoverflow thread How to import existing Objective C classes in Swift

    0 讨论(0)
  • 2021-02-07 12:03

    Why not simply use the Swift pods?-

    pod 'FacebookCore'
    pod 'FacebookLogin'
    pod 'FacebookShare'
    

    and then import as normal, like-

    import FBSDKLoginKit
    import FacebookLogin
    

    Once done, do a clean and build (command/⌘ + Shift + K) and Build (command/⌘ + B). Make sure you are using the .xcworkspace file to open the project.

    More info on Swift FBSDK here.

    Once you use the Swift pods, you should see these Frameworks in your project.

    If you still continue to see the error then "Clean the build folder" using command + shift + alt + K.

    0 讨论(0)
  • 2021-02-07 12:04
    1. Select your Project Target
    2. Go to Build Settings.
    3. Search for Header Search Paths.
    4. Add this value $(SRCROOT)/Pods with recursive, then Xcode will resolve the path for you.

    0 讨论(0)
提交回复
热议问题