• This topic is empty.
Viewing 1 post (of 1 total) Forum home
  • Author
    Posts
  • #7525
    VOGO Technology
    Keymaster

    Real-world case: Firebase, Google Sign-In, MLKit (mobile_scanner) & CocoaPods

    This post documents a real production-level dependency conflict on iOS in a large Flutter project. The goal is to explain why these issues happen, how to diagnose them correctly, and how to apply a single, stable fix — not temporary hacks.

    Technical Context

    Stack involved:

    • Flutter (large-scale app, many plugins)
    • Firebase (firebase_core, firebase_messaging, firebase_auth)
    • Google Sign-In
    • MLKit via mobile_scanner
    • CocoaPods (iOS)

    Main symptom:

    CocoaPods could not find compatible versions for pod “GoogleUtilities/*”

    Seen as:

    • GoogleUtilities/UserDefaults
    • GoogleUtilities/Environment
    • mixed constraints: ~> 7.x, < 8.0, ~> 8.0

    Why this happens (the real reason)

    This is not a Flutter issue.
    This is not a CocoaPods bug.

    It is a structural incompatibility inside the Google iOS ecosystem.

    1. Firebase
    • Firebase 10.x → GoogleUtilities 7.x
    • Firebase 11.x → GoogleUtilities 8.x
    1. Google Sign-In
    • GoogleSignIn 8.x → GoogleUtilities 8.x (via AppCheck)
    1. MLKit (mobile_scanner)
    • mobile_scanner ≤ 5.x
      → MLKitCommon 11.x
      → GoogleUtilities < 8.0

    💥 Result:

    • Firebase 10.x requires 7.x
    • GoogleSignIn 8.x requires 8.x
    • MLKit blocks < 8.0

    ➡️ There is no version combination that can satisfy all three.
    CocoaPods correctly refuses to resolve this graph.

    The common mistake (and why it fails)

    Forcing Firebase in Podfile:

    $FirebaseSDKVersion = ‘10.25.0’

    This may:

    • temporarily “fix” Firebase
    • but immediately breaks Google Sign-In
    • and still conflicts with MLKit

    This is an anti-pattern in modern Flutter projects.

    The correct solution (one stable fix)

    Core rule

    👉 All Google dependencies must be aligned on the same major generation (8.x)

    That means:

    • Firebase 11.x
    • GoogleSignIn 8.x
    • MLKit compatible with GoogleUtilities 8.x

    Final working fix (tested and stable)

    1️⃣ pubspec.yaml

    dependencies:

    firebase_core: ^3.15.2

    firebase_messaging: ^15.2.10

    firebase_auth: ^5.7.0

    google_sign_in: ^6.3.0

    mobile_scanner: ^7.1.4

    ⚠️ Important: mobile_scanner 7.x is mandatory.
    Older versions explicitly block GoogleUtilities < 8.0.

    2️⃣ ios/Podfile

    Remove any Firebase pinning.

    Correct:

    platform :ios, ‘15.0’

    ENV[‘COCOAPODS_DISABLE_STATS’] = ‘true’

    ❌ Incorrect:

    $FirebaseSDKVersion = ‘10.25.0’

    3️⃣ Clean rebuild (strict order)

    cd <project-root>

     

    flutter clean

    rm -rf .dart_tool pubspec.lock

    flutter pub get

     

    ls ios/Flutter/Generated.xcconfig   # must exist

     

    cd ios

    rm -rf Pods Podfile.lock .symlinks Runner.xcworkspace

    pod repo update

    pod install –repo-update

    4️⃣ Xcode

    Open only:

    ios/Runner.xcworkspace

    Never open Runner.xcodeproj.

    Why this fix works

    • Eliminates all 7.x vs 8.x conflicts
    • Avoids forcing CocoaPods
    • Follows Google’s official dependency direction
    • Future-proof against SDK upgrades
    • Prevents subtle runtime crashes (AppCheck, Messaging, Sign-In)

    Key lessons (for large Flutter projects)

    1. Never mix Google dependency generations
    2. Podfile pinning is a last resort, not a solution
    3. In Flutter, dependency issues are solved in pubspec.yaml, not CocoaPods
    4. mobile_scanner is a critical dependency on iOS
    5. If you see GoogleUtilities/* errors → you have a version alignment problem

    Conclusion

    If your Flutter iOS project uses Firebase, Google Sign-In, and MLKit:

    • version alignment is mandatory
    • temporary workarounds will fail again
    • the only stable solution is a coherent, modern Google stack

    Save this post as an advanced troubleshooting reference — it can save days of debugging next time.

     

Viewing 1 post (of 1 total) Forum home
  • You must be logged in to reply to this topic.