Can't import dependency installed with Cocoapods

后端 未结 11 1151
醉梦人生
醉梦人生 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 12:06

    If you use cocoapods, it should have generated a *.xcworkspace file for you. Open this file instead so your project can see the FBSDK installed and has reference to it.

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

    As importing the FBSDKCoreKit.framework etc. will be performed in the [CP] Embed Pods Frameworks build phase when using CocoaPods, you should remove the references to these frameworks in the Embed Frameworks build phase.

    CocoaPods will not create those references, I assume you have tried other ways of importing the Facebooks frameworks, and these link have been created in the process. You can also delete the references to the Facebook frameworks in the Frameworks Folder of you App-Project (the ones in your screenshot written in red, not the ones in the Pods-Project!), but keep the Pods_Runner.framework there.

    From what I can tell, your Linked Frameworks and Libraries section looks valid.

    If it still doesn't work, I'd advise you to create a new Xcode Project with an empty Podfile, and only include the Facebook frameworks via CocoaPods. Importing the Facebook-SDK in the AppDelegate should work then, otherwise I can share a sample project with you. Then you should check your build setting and build phases, maybe something is wrong there. If you still can't figure out the problem, you will probably need to re-create you xcode-project and import all your files again.

    Without a sample Project that reproduces the error, that's the best advise I can give.

    Good Luck! :)

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

    When you install your pods, you must build your application first. Then your imports stop showing errors.

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

    I'll naively suppose you don't have use_frameworks! in you Podfile. If that's true, than you have two ways to go from here:

    1. In your Runner-Bridging-Header.h add #import <FBSDKCoreKit/FBSDKCoreKit.h>, remove import FBSDKCoreKit from AppDelegate.swift and just continue writing the code.

    2. Add use_frameworks! to your Podfile and run pod install again. That might bring some other issues, but if that works, than I'd suggest it.

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

    The above solutions for Header Search Path should work. If you are too lazy to go there. Copy podfile content, remove all pods, pod install, then revert your podfile, pod install again.... Should work ;-)

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