Flutter Firebase plugins linking error iOS when iOS App Extensions are present

Free product design tips

Join our newsletter and get insights that will change your product design perspective

or follow us

social-media-iconsocial-media-iconsocial-media-icon

Introduction

Recently, we have discovered an error that happens during compilation of a Flutter app for iOS when there is both some Firebase plugins and an App Extension(s) present.

The error

ld: warning: Could not find or use auto-linked framework 'Flutter'
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FlutterError", referenced from:
objc-class-ref in firebase_core(FLTFirebasePlugin.o)
"_OBJC_CLASS_$_FlutterMethodChannel", referenced from:
objc-class-ref in firebase_analytics(FLTFirebaseAnalyticsPlugin.o)
objc-class-ref in firebase_core(FLTFirebaseCorePlugin.o)
objc-class-ref in firebase_crashlytics(FLTFirebaseCrashlyticsPlugin.o)
"_FlutterMethodNotImplemented", referenced from:
-[FLTFirebaseAnalyticsPlugin handleMethodCall:result:] in firebase_analytics(FLTFirebaseAnalyticsPlugin.o)
-[FLTFirebaseCorePlugin handleMethodCall:result:] in firebase_core(FLTFirebaseCorePlugin.o)
-[FLTFirebaseCrashlyticsPlugin handleMethodCall:result:] in firebase_crashlytics(FLTFirebaseCrashlyticsPlugin.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Those are the errors that showed up after I added few Firebase plugins to our Flutter application. The small difference between this and other apps is the fact, that ours has an App Extension.

For some reason Xcode was complaining about the lack of Flutter framework in the App Extension, even though it was never used nor referenced inside.

The cause

As it turned out, it's all due to how the linking works in Flutter apps. By default, our App Extension target in the Xcode was inheriting the values from the parent project which contained all the frameworks from Podfile, and hence all the Flutter plugins' pods. Including `firebase_core`, `firebase_analytics`, and `firebase_crashlytics`, as they are the ones that caused the compilation error above.

The solution

Firebase error handling

The solution for this problem was removing those frameworks from the linking and this solved the issue. The steps were:

1. Go to your App Extension target in Xcode.

2. Open Build Settings -> All -> Combined.

3. Locate _Other Linker Flags_.

   Here you'll see all the inherited flags, including stuff like `-framework "firebase_core"`.

4. Remove all the problematic framework references with their corresponding `-framework` prefix AND the `$(inherited)` from the very beginning.

Done!

This solution is based on the [andreasunterhuber's comment] (https://github.com/flutter/flutter/issues/16092#issuecomment-475237976) from a GitHub issue; thank you!

Free product design tips

Join our newsletter and get insights that will change your product design perspective

or follow us

social-media-iconsocial-media-iconsocial-media-icon

Rate this article

No reviews yet!

Learn more about Flutter

Why Firestore, Part I: reasons to love it

Firestore & Firebase suite are great technologies. They allow us to build some features really fast. However, Firestore has also many pain points that outweigh the pros in most of the more advanced cases.

Why Firestore, Part II: reasons to hate it

There is a number of limitations that make using Firestore painful. Tricky latency, data migration problems and complicated privacy are just the beginning of troubles. Read the article to find out why!

Why Firestore, Part III:  6 things you need to know before using Firestore

You need to understand the Firestore limitation and how to overcome them before you build your next web or mobile application using native or crossplatform solutions like Flutter, React Native, or Kotlin.

Why Firestore, Part IV: how to escape it

This is our Final article about Firestore! Did you realize that Firestore makes your life more difficult? If you're looking for the way out, in this part we'll show you how to escape from Firestore!

No match for you?

No problem, send us your resume, we constantly look for new talents. Write on office@leancode.pl