Flutter Firebase - Use of undeclared identifier 'FIRAnalytics'

129 Views Asked by At

I am working on a flutter project on my M3 Macbook and trying to implement FirebaseAnalytics (not first time btw). I followed th guide completely and I got the error;

build error

I tried to clean cache of pub, xcode and simulator. Also upgraded my flutter version from 3.16.9 to 3.19.0. Also tried every single solution request from StackOverflow and Github but no luck. here is my firebase package dependencies;

pubspec.yaml

environment:
  sdk: '>=3.2.6 <4.0.0'

dependencies:
  firebase_analytics: ^10.8.6
  firebase_core: ^2.22.0
  firebase_messaging: ^14.7.15

doctor:

[✓] Flutter (Channel stable, 3.19.0, on macOS 14.3.1 23D60 darwin-arm64, locale
    tr-TR)
    • Flutter version 3.19.0 on channel stable at /Users/taha/Dev/core/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision bae5e49bc2 (6 days ago), 2024-02-13 17:46:18 -0800
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/taha/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.86.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.82.0

XCode Version: 15.2 (15C500b)

MacOS Version: 14.3.1 (23D60)

Thanks in advance

1

There are 1 best solutions below

0
t13n On BEST ANSWER

After trying multiple ways (updating os, cleaning the cache, importing package manually etc.) to overcome this issue realized that cocoapods has a new version. I was using 1.15.1. After updating cocoapods with following command:

sudo gem install cocoapods

Cleared the cache with

pod cache clean --all

Removed following files and folders under ios

.symlinks
Pods
Podfile.lock

and then I installed all pods under project with

pod install

After all it built normally.

I hope it will be useful