Cannot run the Flutter project with Firebase in MacBook M1
Asked Answered
O

8

3

I am trying to build a Flutter project using Firebase on my MacBook Pro M1. Everything was fine until I added the Firebase Core dependency. Now I can't run the project because of the error I'm facing in the debug console which is specified below.

Launching lib/main.dart on iPhone 11 in debug mode...
lib/main.dart:1
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.10.0' defined in 'firebase_core'
    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
      CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because checking is only performed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/8.9.1/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
    [!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
      In Podfile:
        firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 1.11.0, which depends on
          Firebase/CoreOnly (= 8.10.0)
    None of your spec sources contain a spec satisfying the dependency: `Firebase/CoreOnly (= 8.10.0)`.
    You have either:
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:257:in `process_topmost_state'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/resolver.rb:94:in `resolve'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:1078:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:1076:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:416:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:161:in `install!'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command/install.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
    /usr/local/bin/pod:23:in `load'
    /usr/local/bin/pod:23: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: CocoaPods's specs repository is too out-of-date to satisfy dependencies.
To update the CocoaPods specs, run:
  pod repo update

Error running pod install
Error launching application on iPhone 11.

When I run the "pod repo update" command, another error shows up which is specified below.

Updating spec repo `trunk`
objc[3061]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1ef882b90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105c142c8). One of the two will be used. Which one is undefined.
objc[3061]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1ef882be0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105c14318). One of the two will be used. Which one is undefined.

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

### Command


/usr/local/bin/pod repo update


### Report

* What did you do?

* What did you expect to happen?

* What happened instead?


### Stack


   CocoaPods : 1.11.2
        Ruby : ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
    RubyGems : 3.0.3.1
        Host : macOS 12.1 (21C52)
       Xcode : 13.2.1 (13C100)
         Git : git version 2.32.0 (Apple Git-132)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/


### Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0


### Error


LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/ffi_c.bundle' (no such file) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi_c.bundle
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:5:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.15.0/lib/ethon.rb:3:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:440:in `download_typhoeus_impl_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:372:in `download_and_save_with_retries_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:365:in `download_file_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:338:in `download_file'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:78:in `deprecated_local_podspecs'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:60:in `preheat_existing_files'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.2/lib/cocoapods-core/cdn_source.rb:257:in `update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:144:in `block (3 levels) in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:143:in `block (2 levels) in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:142:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:142:in `block in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:140:in `open'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:140:in `update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command/repo/update.rb:23:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'


――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+tried%3A+%27%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle%27+%28mach-o+file%2C+but+is+an+incompatible+architecture+%28have+%27x86_64%27%2C+need+%27arm64e%27%29%29%2C+%27%2Fusr%2Flib%2Fffi_c.bundle%27+%28no+such+file%29+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.5%2Flib%2Fffi_c.bundle&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...
Searching for inspections failed: undefined method `map' for nil:NilClass

I have tried all the possible solutions that were answered under the similar questions such as

  • Terminal is being opened using Rosetta.
  • Installed the ffi with the command "sudo arch -x86_64 gem install ffi" When I try to install pod I'm facing with the following error
Analyzing dependencies
firebase_core: Using Firebase SDK version '8.11.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
  In Podfile:
    firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 1.12.0, which depends on
      Firebase/CoreOnly (= 8.11.0)

None of your spec sources contain a spec satisfying the dependency: `Firebase/CoreOnly (= 8.11.0)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.
  • If I run the "pod repo update" command I get the same error specified in the second block of code.
  • I have also tried removing the Pods and Podfile.lock file and tried to install again running "pod install" command and I have faced the third block of code.
  • I have also tried to update iOS version from 9.0 to 10.0, still didn't work.
name: my_app
description: A new Flutter project.

publish_to: "none"

version: 1.0.0+1

environment:
  sdk: ">=2.15.0 <3.0.0"


dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  firebase_core: ^1.12.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^1.0.0

flutter:
  uses-material-design: true

Even though I have tried probably all of the possible solutions yet I'm officially in the infinite loop. It would be great, If you can help with solving my problem. Thanks in advance.

Overfeed answered 28/1, 2022 at 11:54 Comment(6)
Library/Ruby/Gems/2.6.0/gems/molinillo-0.8 There's your problem. You are trying to use the system Ruby. You can't do that any more. Install your own Ruby and start over.Teplitz
See stackoverflow.com/a/67445580/341994Teplitz
Thanks for your answer. I installed my own Ruby using Homebrew and rbenv as you said but it didn't work.Overfeed
Ever get this solved? I've been struggling with the exact same series of issues/errors as well.Yellowthroat
Yes, see https://mcmap.net/q/1922123/-cannot-run-the-flutter-project-with-firebase-in-macbook-m1 @CoreyStewartOverfeed
@Overfeed I ended up having to do this: #26287603Yellowthroat
O
1

I managed to run the project by navigating to the ios folder of my project directory using the Mac's Terminal and run the "pod update" command. It downloaded the all the related dependencies including Firebase and Pods all over again.

Overfeed answered 29/1, 2022 at 13:16 Comment(0)
D
10

Try this. It works for me on M1 Mac Android Studio.

  1. Install ffi
sudo arch -x86_64 gem install ffi
  1. Navigate to IOS folder. Remove Pod lock file.
rm -rf Podfile.lock
  1. Update pod repo
arch -x86_64 pod repo update
  1. install pods
arch -x86_64 pod install
Dramatics answered 7/6, 2022 at 20:13 Comment(1)
These steps all ran for me - though I needed to sudo all the arch commands. But this did nothing to resolve the issue for me. :(Hexosan
O
4

You must set the iOS version in your Podfile.

  1. Open your Podfile using TextEdit

You will see these two lines there.

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

You need to delete the hashtag then change your ios version to 10.0

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

Save it, then run "arch -x86_64 pod install", you are ready.

Oblast answered 28/1, 2022 at 13:6 Comment(5)
That is not the error. That is only a warningOutpoint
It didn't solve my problem but thanks anyway.Overfeed
Stijn2210 Firebase only works when Podfile is in 10.0, @Overfeed what is the error you get now, still the same? Don't forget to use "arch -x86_64" while "pod install".Oblast
I updated the Podfile to 10.0 still I'm getting the same error while running "arch -x86_64 pod install" commandOverfeed
First, try to delete Podfile.lock file. Then try "arch -x86_64 pod install" again.Oblast
F
2
  1. Go to terminal and open it with Rosetta
  2. Write this command in terminal
    sudo gem install cocoapods
    
  3. Then write this to collect problem for M1 Apple laptop
    sudo gem install ffi
    
  4. Now, make pod init
  5. Now, pod install
Ferrell answered 20/2, 2022 at 20:3 Comment(0)
O
1

I managed to run the project by navigating to the ios folder of my project directory using the Mac's Terminal and run the "pod update" command. It downloaded the all the related dependencies including Firebase and Pods all over again.

Overfeed answered 29/1, 2022 at 13:16 Comment(0)
O
0

I’ve had this problem before. Update your Firebase packages in your pubspec.yaml to the latest versions (check pub.dev which versions those are). Once you’ve installed those, delete your Podfile.lock in your iOS folder and run sudo arch -x86_64 pod repo update and then arch -x86_64 pod install. This should solve your Firebase error.

Outpoint answered 28/1, 2022 at 11:59 Comment(5)
Although I have updated the Firebase package and run pod install after deleting the Podfile.lock file, my problem still exists but thanks for your response.Overfeed
Can you show me your pubspec.yaml file?Outpoint
Sure, I added above.Overfeed
I ran into the same problem yesterday again. I edited my answer! Basically you need to run pod repo update before pod installOutpoint
When I run "pod repo update", I have faced an error as before. Instead I run "pods update" command on Terminal and it worked. Thanks anyway.Overfeed
D
0

IN 11-10-2022:

My mac: macOS Monterey, version 12.6 , xcode version:14.0.1, Flutter version: 3.0.0

If you already added Firebase into your pubspec.yaml please comment it and run pub get, and follow below steps:

  1. Please login into firebase console.

  2. I have integrated firebase using firebase cli tools.(Please follow this link https://firebase.google.com/docs/flutter/setup?platform=ios).(once you have installed Cli tools using your mac terminal and you can login from your terminal using Firbase login you can switch into your IDE's terminal and add the Firebase projects.All of the commands are available in the above link)

  3. If there is any warning shows in terminal of your IDE, Please do the necessary steps(May be warning like '...is not in your path please add it into your path ', in my case i had run: export PATH="$PATH":"$HOME/.pub-cache/bin" from my IDE terminal) if not please follow and run pub get or try to run the project.

  4. May show error in pod install showing your cocopods is too old and will show the required command to run from your IDE terminal(in my case: pod repo update).

  5. Please try to run your project again.(it will take long time to run pod install .In my case first build failed with some error ,when i tried to run again build succeeded).

Hope it helps..

Demonolater answered 12/10, 2022 at 5:53 Comment(0)
P
0

Setup firebase as in official documentation and then follow the follwoing steps for running on emulators:

For Android setup:

In android/app/build.gradle:

 android {                                                                                     
   defaultConfig {
        minSdkVersion 21
        multiDexEnabled true
    }                                                                                      
 }
 android {                                                                                     
   compileSdkVersion 33                                                                                      
 }

In android/build.gradle:

buildscript {
      dependencies {
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

For iOS setup:

In iOS podfile

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

In terminal open root directory of your project and do:

cd ios
sudo gem install ffi
rm -rf Pods Podfile.lock
pod cache clean --all
pod install

Now finally run on iOS simulator (pod install and XCode build will take a lot of time in 1st run for an app)

*Note Firebase CLI and Flutter SDK should be latest updated as of June, 2023

Pandora answered 12/6, 2023 at 18:41 Comment(0)
M
-1

These are the notes I did when fixing this issue. Good luck :)

Device: MBP 16” M1 Pro 2022

OS: 12.4

Issue - application not running iOS simulator. Gems were installed under old Ruby version that comes preinstalled.

I am not sure what exactly fixed the issue but this was I did:

  1. Update OS
  2. Update XCode
  3. Install Ruby 3
  4. Update Gems
  5. Update / Install CocoaPods
  6. !!Add command line tools to XCode.

Links:

Mcclimans answered 19/9, 2022 at 6:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.