Cannot Import Firebase Into Swift Class

后端 未结 11 1800
[愿得一人]
[愿得一人] 2020-12-03 06:29

I am totally new to Firebase and building iOS apps. In Xcode 7, I am trying to import Firebase into my Swift class. In a swift file, I have typed \"import Firebase\".

相关标签:
11条回答
  • 2020-12-03 07:19

    When using the CocoaPods installation method, you can start by removing the project workspace file:
    rm -rf MyProject.xcworkspace

    Then, edit the Podfile to following, which will be automatically set for the latest version of Firebase:

    use_frameworks! 
    target 'MyProject' do
      pod 'Firebase/Core'
      pod 'Firebase/Database'
    end
    
    target 'MyProjectUITests' do
      pod 'Firebase/Core'
      pod 'Firebase/Database'
    end
    

    Finally, reinstall the pod

    pod install
    
    0 讨论(0)
  • 2020-12-03 07:23

    If you have added the firebase framework manually, delete it and add it again.Rebuild the project and it will work.

    There seems to be a bug.This happens when you discard the changes.

    0 讨论(0)
  • 2020-12-03 07:25

    In your Podfile make sure to have pod 'Firebase' in addition to your pod 'Firebase/Core' After, :wq from vim and run a command pod update. Make sure to open .xcworkspace

    0 讨论(0)
  • 2020-12-03 07:27

    Those who are using swift 3 are welcome to try this. It worked for me.

    My pod file:

    platform :osx, '9.0'
    use_frameworks!
    
    target 'MyProject' do
      pod 'Firebase/Messaging'
      pod 'Firebase'
    end
    

    AppDelegate:

    import FirebaseCore
    import FirebaseMessaging
    
    0 讨论(0)
  • 2020-12-03 07:30

    For me it was this:

    The Framework is called FirebaseAnalytics now and not Firebase.

    The official documentation even has this wrong.

    So after installing with CocoaPods (Firebase version 3.4.0) this works:

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