<p dir="auto">Currently, developing a flutter project that includes swift can be a bit of a pain when including various plugins - in particular Firebase messaging is the one I've had trouble with.</p>
<p dir="auto">This is more or less the structure of (the iOS part) of my app:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="App
  ↳ swift source
  ↳ firebase messaging
    ↳ objc source
    ↳ various static libraries included in sub-pods etc
  ↳ Qr code plugin
    ↳ objc source (originally swift but had issues with that)
    ↳ Google MobileVision (objc source)
      ↳ various static libraries included as sub-pods etc
  ↳ Swift plugin(s) (source, no libraries)
  ↳ Objc plugin(s) (source, no libraries)"><pre class="notranslate"><code class="notranslate">App
  ↳ swift source
  ↳ firebase messaging
    ↳ objc source
    ↳ various static libraries included in sub-pods etc
  ↳ Qr code plugin
    ↳ objc source (originally swift but had issues with that)
    ↳ Google MobileVision (objc source)
      ↳ various static libraries included as sub-pods etc
  ↳ Swift plugin(s) (source, no libraries)
  ↳ Objc plugin(s) (source, no libraries)
</code></pre></div>
<p dir="auto">Because of my usage of swift, <code class="notranslate">use_frameworks!</code> is set in my Podfile.</p>
<p dir="auto">What's happening when I build currently is that the various libraries are each being build as dynamic frameworks i.e. Firebase, qr code pluign, swift plugin(s), objc plugin(s). Then it appears that the static libraries are being linked properly when running on the device, but when I do an achive build, upload to testflight, and run on the device it fails to run. As far as I can tell, the static libraries are being linked into the main app rather than the dynamic libraries where they're required (i.e. firebase), although I may be misdiagnosing that as I'm not an expert by any means.</p>
<p dir="auto">I do have an example project but the issue is that to actually reproduce the issue you have to archive it, upload to app store, and use testflight etc to run it; I sometimes saw issues with release builds after running <code class="notranslate">flutter build ios --release</code> but not always for some reason.</p>
<p dir="auto">This is the error though, although not all that detailed as it's hard to debug an app from testflight:<br>
<code class="notranslate">Termination Description: DYLD, Symbol not found: _OBJC_CLASS_$_FIRApp | Referenced from: /private/var/containers/Bundle/Application/A9C35A12-B9A3-4F0C-A508-C0554CA2843A/Runner.app/Frameworks/firebase_messaging.framework/firebase_messaging | Expected in: flat namespace | in /private/var/containers/Bundle/Application/A9C35A12-B9A3-4F0C-A508-C0554CA2843A/Runner.app/Frameworks/firebase_messaging.framework/firebase_messaging</code></p>
<p dir="auto">What I'd like to propose is some way of forcing cocoapods to do what is needed (i.e. link the libraries into the right place). I tried various things including manually specifying the name of the dependency libraries in the podspec of the framework including them, which did link them into the dynamic framework but then resulted in duplicate definitions of classes and all sorts of other fun issues. I'm sure it's possible but that I just couldn't figure it out.</p>
<p dir="auto">However, cocoapods does have a relatively new option introduced in 1.4.0 - static_framework. To use it, you simply specify <code class="notranslate">static_framework = true</code> in the podspec of the framework which includes a static library, and the framework will compile statically including the dependent libraries (it should also theoretically remove the requirement for the `s.pod_target_xcconfig = { 'FRAMEWORK_SEARCH_PATHS .... OTHER_LDFLAGS ...' currently in firebase_messaging.podspec (and I assume the other plugins as well).</p>
<p dir="auto">There are a couple of caveats to this - the first being that CocoaPods currently has <a href="https://github.com/CocoaPods/CocoaPods/issues/7463" data-hovercard-type="issue" data-hovercard-url="/CocoaPods/CocoaPods/issues/7463/hovercard">a bug</a> that means public_headers which are symlinked from outside the project (as flutter has recently started doing) get included as <code class="notranslate">Project Headers</code> instead of <code class="notranslate">Public Headers</code> at least for when static_framework is used (it might pop up other places too). I've submitted <a href="https://github.com/CocoaPods/CocoaPods/pull/7470" data-hovercard-type="pull_request" data-hovercard-url="/CocoaPods/CocoaPods/pull/7470/hovercard">a PR</a> to cocoapods to resolve that <del>but still need to write some unit tests for them (yay, I get to learn more ruby <g-emoji class="g-emoji" alias="unamused" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f612.png">😒</g-emoji>)</del> <em>(edit: it has now been accepted into master but no idea about release date)</em>. Also, FYI - the trunk of cocoapods seems to not work with flutter (I don't currently have time to track down why not) so the next release that includes this fix could theoretically fail on that. It will also require people to update to cocoapods 1.4.0 if they haven't already.</p>
<p dir="auto">Sorry for the long-windedness, but I think this is something worth considering especially now that more developers will hopefully be coming on board since the beta release - and I'd bet that a lot of them will want to use both swift and the various plugins flutter provides for firebase etc.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="10-03 11:29:10.612 29886 29912 E flutter : [ERROR:../../lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
10-03 11:29:10.612 29886 29912 E flutter : The null object does not have a method 'inheritFromWidgetOfExactType'.
10-03 11:29:10.612 29886 29912 E flutter : 
10-03 11:29:10.612 29886 29912 E flutter : NoSuchMethodError: method not found: 'inheritFromWidgetOfExactType'
10-03 11:29:10.612 29886 29912 E flutter : Receiver: null
10-03 11:29:10.612 29886 29912 E flutter : Arguments: [Type: class 'FormScope']
10-03 11:29:10.612 29886 29912 E flutter : #0      Object._noSuchMethod (dart:core-patch/object_patch.dart)
10-03 11:29:10.612 29886 29912 E flutter : #1      Object.noSuchMethod (dart:core-patch/object_patch.dart)
10-03 11:29:10.612 29886 29912 E flutter : #2      _FormFieldData.onChanged (package:flutter/src/material/input.dart)
10-03 11:29:10.612 29886 29912 E flutter : #3      RawInputLineState._handleTextUpdated (package:flutter/src/widgets/editable.dart)
10-03 11:29:10.612 29886 29912 E flutter : #4      _KeyboardClientImpl.updateEditingState (package:flutter/src/widgets/editable.dart)
10-03 11:29:10.612 29886 29912 E flutter : #5      _KeyboardClientStubControl.handleMessage (package:sky_services/editing/editing.mojom.dart)
10-03 11:29:10.612 29886 29912 E flutter : #6      StubMessageHandler.handleRead (package:mojo/src/stub.dart)
10-03 11:29:10.612 29886 29912 E flutter : #7      MojoEventHandler._handleEvent (package:mojo/src/event_handler.dart)
10-03 11:29:10.612 29886 29912 E flutter : #8      MojoEventHandler._tryHandleEvent (package:mojo/src/event_handler.dart)
10-03 11:29:10.612 29886 29912 E flutter : #9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart)"><pre class="notranslate"><code class="notranslate">10-03 11:29:10.612 29886 29912 E flutter : [ERROR:../../lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
10-03 11:29:10.612 29886 29912 E flutter : The null object does not have a method 'inheritFromWidgetOfExactType'.
10-03 11:29:10.612 29886 29912 E flutter : 
10-03 11:29:10.612 29886 29912 E flutter : NoSuchMethodError: method not found: 'inheritFromWidgetOfExactType'
10-03 11:29:10.612 29886 29912 E flutter : Receiver: null
10-03 11:29:10.612 29886 29912 E flutter : Arguments: [Type: class 'FormScope']
10-03 11:29:10.612 29886 29912 E flutter : #0      Object._noSuchMethod (dart:core-patch/object_patch.dart)
10-03 11:29:10.612 29886 29912 E flutter : #1      Object.noSuchMethod (dart:core-patch/object_patch.dart)
10-03 11:29:10.612 29886 29912 E flutter : #2      _FormFieldData.onChanged (package:flutter/src/material/input.dart)
10-03 11:29:10.612 29886 29912 E flutter : #3      RawInputLineState._handleTextUpdated (package:flutter/src/widgets/editable.dart)
10-03 11:29:10.612 29886 29912 E flutter : #4      _KeyboardClientImpl.updateEditingState (package:flutter/src/widgets/editable.dart)
10-03 11:29:10.612 29886 29912 E flutter : #5      _KeyboardClientStubControl.handleMessage (package:sky_services/editing/editing.mojom.dart)
10-03 11:29:10.612 29886 29912 E flutter : #6      StubMessageHandler.handleRead (package:mojo/src/stub.dart)
10-03 11:29:10.612 29886 29912 E flutter : #7      MojoEventHandler._handleEvent (package:mojo/src/event_handler.dart)
10-03 11:29:10.612 29886 29912 E flutter : #8      MojoEventHandler._tryHandleEvent (package:mojo/src/event_handler.dart)
10-03 11:29:10.612 29886 29912 E flutter : #9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart)
</code></pre></div>