skip to Main Content

I’m trying to incorporate Firebase Analytics into my SwiftUI project in Xcode. I’ve added the Firebase package using Swift Package Manager, and am able to call FirebaseApp.configure() to initialize my app in my UIApplicationDelegate class. Now I’m trying to log analytics events and am running into an issue.

My UIApplicationDelegate class is in an iOS-specific folder. I have a service class that is in a Shared folder (to be used across both iOS and macOS builds). In my service class, I’ve added a line that says:

import Firebase

However, when I go to build my iOS target I get an error saying:

No such module 'Firebase'

I don’t know why this import statement would cause a problem, since I have the very same statement in my UIApplicationDelegate class. The only thing I could think of was that somehow my Shared classes don’t know about Firebase? Maybe? When I view the iOS target in my project it shows that the FirebaseCrashlytics and FirebaseAnalytics frameworks have been added to it.

I’m at a loss as to what’s happening. All other things I’ve found online are for Cocoapods, which I’m not using for dependency management. I’m leveraging the Swift Package Manager for this. Any help would be greatly appreciated!!

3

Answers


  1. I had the same issue but the post below from GitHub should fix it:

    https://github.com/firebase/firebase-ios-sdk/issues/9014#issuecomment-979489434

    Login or Signup to reply.
  2. After installing the Firebase swift package, make sure you add the Firebase libraries to Frameworks:

    TARGETS -> Your App -> General -> Frameworks, Libraries, and Embedded Content -> hit ‘+’ to add the Firebase libraries you want:

    enter image description here

    Login or Signup to reply.
  3. I had the same error but with ‘FirebaseCore’. I tried everything, but what worked for me was to add @_implementationOnly to import. So it should look like this:

    @_implementationOnly import FirebaseCore
    

    Here is the link that helped me and it says:

    You could use @_implementationOnly import for the modules from the
    third-party SDK if you aren’t using anything from that SDK as part of
    your module’s public interface.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search