5

We're trying to use firebase analytics in our ios app.

Default events seems to be logged with no problem.

5.1.0 - [Firebase/Analytics][I-ACS023072] Event logged. Event name, event params: screen_view (_vs)

However, only custom event is not logged with this log below.

5.1.0 - [Firebase/Analytics][I-ACS025018] Event not logged. Call +[FIRApp configure]: custom_event_name

I think configurating is following the document. We have two different project's plist for each targets to setting up development environment to use different Firebase projects based on build type or target.

guard let path = Bundle.main.path(forResource: googleServiceInfoPlist, ofType: "plist"),
  let opts = FirebaseOptions(contentsOfFile: path) else {
  fatalError("Couldn't load config file")
}
FirebaseApp.configure(options: opts)

I guessed multiple plists causes this problem at first, but there was no changes with a GoogleService-Info.plist and calling FirebaseApp.configure() .

Sending event's func is just like this.

private func sendToFirebase(_ event: Trackable) {
 Analytics.logEvent(event.name, parameters: event.properties)
}

What are the possible causes?

Thank you.

2
  • why you use this FirebaseApp.configure(options: opts) ,as firebase documentation it's use as FirebaseApp.configure()
    – Yatendra
    Commented Jul 6, 2018 at 7:05
  • Because I need to switch plist based on target. firebase.google.com/docs/configure/… @Yatendra
    – fxwx23
    Commented Jul 6, 2018 at 7:13

3 Answers 3

4

I solved by myself.

This is caused by setting up cocoapods for embedded framework.

My Podfile was like below,

platform :ios, '11.0'
swift_version = '4.1'
use_frameworks!

target 'AppCore' do
  pod 'Firebase/Core'

  target 'App' do
    inherit! :search_paths
  end
end

AppCore is embedded framework.

pod 'Firebase/xxx' should be targeted to main app, not embedded framework.

I did:

  • Eliminate dependency of Firebase from embedded framework
  • Fixed podfile not targeting to embedded framework

then tracked customs events correctly.

3
  • I'm looking for the solutions like this, but I couldn't fully understand what you wrote. Could you explain more about this? I wonder the final version of Podfile you're using which solves this issue. Commented Jul 22, 2019 at 12:01
  • I solved this issue by moving pod 'Firebase/Core' to main target, not embedded framework target.
    – fxwx23
    Commented Jul 23, 2019 at 13:12
  • Thanks for the reply. We need to use Firebase dependency in both targets. I did a workaround that I place Firebase/Core to the App target and use inherit! :search_paths in AppCore target. (And App target includes AppCore target which is opposite to your Podfile above) Commented Jul 24, 2019 at 15:00
0

I solved this issue with manually adding the Firebase Analytics SDK https://firebase.google.com/docs/ios/setup#frameworks

0

I encountered this in my project, turns out I forgot to add @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate in the @main struct. Ref: https://firebase.google.com/docs/ios/setup#frameworks

@main
struct YourApp: App {
  // register app delegate for Firebase setup
  @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate // here

  var body: some Scene {
    WindowGroup {
      NavigationView {
        ContentView()
      }
    }
  }
}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.