Rating: 5.00 / 5 Based on 28 reviews
Recently, we have discovered an error that happens during the compilation of a Flutter app for iOS when there is both Firebase plugins and an App Extension(s) present.
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 a 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.
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 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!