firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.66k stars 1.49k forks source link

Analytics Integration Issue - SPM, 10.3.0 #10644

Closed mgrms closed 6 months ago

mgrms commented 1 year ago

Description

Firebase Analytics SPM integration docs does not contain step about adding "-ObjC" to "Other Linker Flags". CocoaPods do that automatically, but with SPM you need to do that manually, or Firebase Analytics won't work at all.

Just spent a few hours to find this problem.

I think it will be nice to update the docs. (https://firebase.google.com/docs/analytics/get-started?platform=ios#add-sdk)

Reproducing the issue

Create new project, integrate FirebaseAnalytics into UIKit project via SPM.

Firebase SDK Version

10.3.0

Xcode Version

14.2

Installation Method

Swift Package Manager

Firebase Product(s)

Analytics

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

No response

If using CocoaPods, the project's Podfile.lock

No response

google-oss-bot commented 1 year ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

rizafran commented 1 year ago

Thanks for raising this, @mgrms. Adding -ObjC linker option is listed on the requirements here, but I'll inform the team for this to be added as well on the docs.

rizafran commented 1 year ago

@mgrms, I just noticed that this step is already on our documentation. Please see our installation guide for more info.

mgrms commented 1 year ago

@rizafran

Thanks, now I see that page you mentioned indeed contains this step. But to be honest, I think it's still worth adding this step directly to Analytics installation page (https://firebase.google.com/docs/analytics/get-started?platform=ios#add-sdk), since it won't work without this step at all. Will be much clearer for people who use Firebase for the first time.

Reference to page you mentioned says: "Visit our installation guide to learn about the different ways you can add Firebase SDKs to your Apple project, including importing frameworks directly and using CocoaPods."

So I thought it's all about different ways of installing Firebase (CocoaPods, Carthage) which was not my case, and didn't even look there.

I will close this now. Thanks for your help!

paulb777 commented 1 year ago

I'll reopen, since I agree that we should add to the Analytics installation page.

joshuapoq commented 8 months ago

@paulb777 I don't believe the ObjC flag is required anymore? Asking as it causes conflicts with 3rd parties that statically embed Firebase (which is also wrong so it's good to catch). But I think this issue is no longer an issue so are there plans to remove it from documentation or is it still required?

paulb777 commented 7 months ago

@joshuapoq It's now less required.

If the app uses an API from FirebaseAnalytics, it will be fully linked without the use of the -ObjC option.

If FirebaseAnalytics is used without any of its APIs, then -ObjC is still needed.

paulb777 commented 6 months ago

The docs have been updated.