Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [firebase_core] IOS build issue "fatal error: module 'firebase_core' not found" #6370

Closed
RtypeStudios opened this issue Jun 11, 2021 · 8 comments
Labels
Needs Attention This issue needs maintainer attention. resolution: user This was a user issue, e.g. invalid configuration or code. type: bug Something isn't working

Comments

@RtypeStudios
Copy link

Bug report

Describe the bug
When building the IOS version of a flutter application the following error is thrown:

Running pod install...                                           2,399ms
Running Xcode build...                                          
Xcode build done.                                           149.7s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    /Users/appveyor/projects/applications/app_customer/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'firebase_core' not found
    @import firebase_core;
     ~~~~~~~^~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
Encountered error while building for device.

Build is occurring on CI server with OSX 10.15
Ruby version is 2.6.5

Steps to reproduce

Steps to reproduce the behavior:

  1. "cd" into ios directory
  2. Run "pod init"
  3. Edit Podfile to be:
     platform :ios, '10.0'

     target 'Runner' do
        use_frameworks!
        pod 'Firebase/Messaging'
        pod 'Firebase/Analytics'
        pod 'Firebase/Core'
     end
  1. Run "pod install"
  2. Build with:
flutter build ios --release --no-codesign

Expected behavior

Expected completed build without error.

Additional context

None


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, 2.2.0-10.3.pre, on Microsoft Windows [Version 10.0.19043.1052], locale en-AU)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[!] Android Studio (not installed)
[√] VS Code (version 1.56.2)
[√] Connected device (2 available)
    ! Device R52N10VZK6B is not authorized.
      You might need to check your device for an authorization dialog.

! Doctor found issues in 2 categories.

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.13.0-211.14.beta
Flutter SDK 2.2.0-10.3.pre
livevenue 1.0.0+1

dependencies:
- awesome_card 1.1.5 [flutter]
- cached_network_image 3.0.0 [flutter flutter_cache_manager octo_image]
- carousel_slider 4.0.0-nullsafety.0 [flutter]
- collection 1.15.0
- credit_card_validator 2.0.0-nullsafety.0 [credit_card_type_detector]
- dio 4.0.0 [http_parser path]
- equatable 2.0.0 [collection meta]
- firebase_core 1.2.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_messaging 10.0.1 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_bloc 7.0.0 [flutter bloc provider]
- flutter_secure_storage 4.2.0 [meta flutter]
- font_awesome_flutter 9.0.0 [flutter]
- formz 0.4.0
- geolocator 7.0.3 [flutter geolocator_platform_interface geolocator_web]
- intl 0.17.0 [clock path]
- livevenue_api 0.0.1 [dio flutter_secure_storage intl flutter]
- livevenue_common 0.0.1 [dio flutter_secure_storage intl flutter]
- mask_text_input_formatter 2.0.0-nullsafety.2 [flutter]
- overlay_support 1.2.1 [flutter async]
- package_info 2.0.0 [flutter]
- qr_code_scanner 0.4.0 [flutter]
- rxdart 0.27.0
- shimmer 2.0.0 [flutter]
- stripe_sdk 5.0.0-nullsafety.0 [flutter http url_launcher mask_text_input_formatter flutter_slidable simple_animations supercharged awesome_card uni_links2 credit_card_validator collection]
- url_launcher 6.0.3 [flutter url_launcher_platform_interface url_launcher_linux url_launcher_macos url_launcher_windows url_launcher_web]

dev dependencies:
- effective_dart 1.3.1
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- archive 3.1.2 [crypto path]
- async 2.6.1 [meta collection]
- bloc 7.0.0 [meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- characters 1.1.0
- charcode 1.2.0
- clock 1.1.0
- credit_card_type_detector 2.0.0-nullsafety.0
- crypto 3.0.1 [collection typed_data]
- fake_async 1.2.0 [clock collection]
- ffi 1.0.0
- file 6.1.0 [meta path]
- firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface]
- firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_messaging_platform_interface 3.0.1 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 2.0.1 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- flutter_blurhash 0.6.0 [flutter meta pedantic]
- flutter_cache_manager 3.0.2 [clock collection file flutter http image path path_provider pedantic rxdart sqflite uuid]
- flutter_slidable 0.6.0 [flutter]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- geolocator_platform_interface 2.0.2 [flutter plugin_platform_interface vector_math meta]
- geolocator_web 2.0.3 [flutter flutter_web_plugins geolocator_platform_interface]
- http 0.13.3 [async http_parser meta path pedantic]
- http_parser 4.0.0 [charcode collection source_span string_scanner typed_data]
- image 3.0.2 [archive meta xml]
- js 0.6.3
- matcher 0.12.10 [stack_trace]
- meta 1.3.0
- nested 1.0.0 [flutter]
- octo_image 1.0.0+1 [flutter flutter_blurhash]
- path 1.8.0
- path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 2.0.0 [flutter]
- path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface]
- path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.11.0
- petitparser 4.1.0 [meta]
- platform 3.0.0
- plugin_platform_interface 2.0.0 [meta]
- process 4.2.1 [file path platform]
- provider 5.0.0 [collection flutter nested]
- simple_animations 3.1.1 [flutter supercharged pedantic]
- sky_engine 0.0.99
- source_span 1.8.1 [collection path term_glyph]
- sqflite 2.0.0+3 [flutter sqflite_common path]
- sqflite_common 2.0.0+2 [synchronized path meta]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- string_scanner 1.1.0 [charcode source_span]
- supercharged 2.0.0 [supercharged_dart flutter]
- supercharged_dart 2.0.0
- synchronized 3.0.0
- term_glyph 1.2.0
- test_api 0.3.0 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0 [collection]
- uni_links2 0.6.0+2 [uni_links2_platform_interface uni_links_web2 flutter]
- uni_links2_platform_interface 1.0.0+2 [plugin_platform_interface flutter]
- uni_links_web2 0.1.0+2 [uni_links2_platform_interface flutter flutter_web_plugins]
- url_launcher_linux 2.0.0 [flutter]
- url_launcher_macos 2.0.0 [flutter]
- url_launcher_platform_interface 2.0.2 [flutter plugin_platform_interface]
- url_launcher_web 2.0.0 [url_launcher_platform_interface meta flutter flutter_web_plugins]
- url_launcher_windows 2.0.0 [flutter]
- uuid 3.0.4 [crypto]
- vector_math 2.1.0
- win32 2.0.5 [ffi]
- xdg_directories 0.2.0 [meta path process]
- xml 5.1.0 [collection meta petitparser]

@RtypeStudios RtypeStudios added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jun 11, 2021
@markusaksli-nc markusaksli-nc added the triage Issue is currently being triaged. label Jun 11, 2021
@markusaksli-nc
Copy link
Contributor

Hi @RtypeStudios
Why are you adding the native pods to the podfile?
Please follow the instructions at https://firebase.flutter.dev/docs/overview and https://firebase.flutter.dev/docs/installation/ios
Thank you

@markusaksli-nc markusaksli-nc added resolution: user This was a user issue, e.g. invalid configuration or code. and removed triage Issue is currently being triaged. labels Jun 11, 2021
@RtypeStudios
Copy link
Author

HI Markusakli,

So sorry! thanks for the reply. I thought I needed to add them manually because of the error below. I was just trying to trouble shoot it and I got really off path by the looks of things. :)

With cocoapods removed (using "pod deintergrate") the returned build error is:

CocoaPods' output:
↳
      Preparing
    Analyzing dependencies
    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
    firebase_core: Using Firebase SDK version '8.0.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_messaging` from `.symlinks/plugins/firebase_messaging/ios`
    firebase_messaging: Using Firebase SDK version '8.0.0' defined in 'firebase_core'
    -> Fetching podspec for `flutter_secure_storage` from `.symlinks/plugins/flutter_secure_storage/ios`
    -> Fetching podspec for `geolocator` from `.symlinks/plugins/geolocator/ios`
    -> Fetching podspec for `package_info` from `.symlinks/plugins/package_info/ios`
    -> Fetching podspec for `path_provider` from `.symlinks/plugins/path_provider/ios`
    -> Fetching podspec for `qr_code_scanner` from `.symlinks/plugins/qr_code_scanner/ios`
    -> Fetching podspec for `sqflite` from `.symlinks/plugins/sqflite/ios`
    -> Fetching podspec for `uni_links2` from `.symlinks/plugins/uni_links2/ios`
    -> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`
    Resolving dependencies of `Podfile`
    Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/`
      CDN: trunk Relative path downloaded: CocoaPods-version.yml, save ETag: "60c41f72-38"
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
    [!] CocoaPods could not find compatible versions for pod "firebase_core":
      In Podfile:
        firebase_core (from `.symlinks/plugins/firebase_core/ios`)
    Specs satisfying the `firebase_core (from `.symlinks/plugins/firebase_core/ios`)` dependency were found, but they required a higher minimum deployment target.
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:254:in `process_topmost_state'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/resolver.rb:94:in `resolve'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1074:in `block in resolve_dependencies'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/bin/pod:23:in `load'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/bin/pod:23:in `<main>'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
    /Users/appveyor/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
Error output from CocoaPods:
↳
    [!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Error running pod install

If I then add a Podfile with below to resolve the "no platform was specified"

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

target 'Runner' do
  # Comment the next line if you don't want to use dynamic frameworks
  #use_frameworks!
end

I get a new error:

Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    /Users/appveyor/projects/applications/app_customer/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'firebase_core' not found
    @import firebase_core;
     ~~~~~~~^~~~~~~~~~~~~
    1 error generated.
    /Users/appveyor/projects/applications/app_customer/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'firebase_core' not found
    @import firebase_core;
     ~~~~~~~^~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
Encountered error while building for device.

@RtypeStudios
Copy link
Author

I have dug further into this and the only solution I have been able to find is to copy the below into my podfile from the example here: https://github.com/sbis04/flutterfire-samples/blob/master/ios/Podfile

I don't entirely understand what is going on here and this seems to be a large departure from the instructions provided in the documentation. It concerns me to have code I don't understand are you able to shed any light on what is going on here?

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)

  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end

  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"

end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
    end
  end
end

@markusaksli-nc
Copy link
Contributor

This podfile looks mostly like the flutter default one except for the manual step of setting the deployment target for each build configuration. It looks like the issue was caused by some non standard setup in your podfile (such as use_frameworks! being commented out). In general the default podfile generated by flutter at flutter create or flutter pub get if you have deleted it will work with all of the FlutterFire plugins, provided that you have set the appropriate deployment target version. You can do this by either uncommenting the

# platform :ios, '10.0'

line or setting it manually in Xcode.

@RtypeStudios
Copy link
Author

Hi @markusaksli-nc!

Thank you for you reply!

Are you saying by default my pod file should have looked like the above example I posted minus the deployment target change?

because, I tried to run the commands as you mentioned but I'm not seeing any default pod file being created:

  1. I ran "flutter create test" (no pod file).
  2. Then Edited "pubspec.yaml" to include "firebase_messaging" in the deps.
  3. I ran "flutter pub get" (no pod file).

Is there an option I'm missing? I'm on Windows / Linux would that be the reason?

If I do "pod init" manually in the IOS directory I get the following:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'Runner' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Runner

end

This pod file gives me this error, which is where I started with:.

/Users/appveyor/projects/applications/app_customer/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'firebase_core' not found
    @import firebase_core;

Sorry for all the hassle, I'm just trying to understand what I have done wrong.

@markusaksli-nc
Copy link
Contributor

markusaksli-nc commented Jun 15, 2021

Yeah the podfile generated by pod init will not work because it lacks any of the required flutter podfile setup.

It could be that building for iOS (with flutter run or flutter build ios is what generates the file instead of just pub get (which is a step in the build process)? I haven't dug into the flutter_tool code all that much so I'm not sure what step it occurs at. Either way you need flutter to generate the podfile, you can't just use pod init. The current flutter-generated podfiles are at https://github.com/flutter/flutter/tree/master/packages/flutter_tools/templates/cocoapods

Although adding these manually should not be necessary in most use cases (see flutter/flutter#41982 (comment)).

@RtypeStudios
Copy link
Author

From testing:

Windows 10 + "flutter run" - No PodFile
Windows 10 + "flutter build appbundle" - No PodFile
Windows 10 + "flutter build ios" - Building for iOS is only supported on macOS.

OSX + "flutter run" - Cant test as it is a remote CI server.
OSX + "flutter build ios" - Creates a pod file.

With the all of the manually added pod stuff removed. The build does create the pod file but fails with this error:

Automatically assigning platform iOSwith version9.0on targetRunner because no platform was specified. Please specify a platform for this target in your Podfile

So if the pod files is created during the build, how can I set the "platform :ios, '9.0'"?

Or is the solution to copy the podfile from my CI server and check it in?

Thanks!

@RtypeStudios
Copy link
Author

Found the answer:

Update all of the places this appears:

IPHONEOS_DEPLOYMENT_TARGET = 9.0;

and replace it with:

IPHONEOS_DEPLOYMENT_TARGET = 10.0;

All appears to be building now. Thank you for your time!

@firebase firebase locked and limited conversation to collaborators Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Attention This issue needs maintainer attention. resolution: user This was a user issue, e.g. invalid configuration or code. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants