1

After I setup my Flutter application with Firebase and connecting the app with the Firebase console, I am not able to run the application in the iOS simulator.

My system description is - 2017 Macbook Pro Intel i5 & MacOS 13.6.7.

Simulator - iPhone 12 Pro Max iOS 17.2

The debug console shows the main error as -

Error running pod install
Error launching application on iPhone 12 Pro Max.

Ruby version on my mac after running ruby -v

ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin22]

The application runs fine without setting up the Firebase. I tried a lot of things but still unable to figure out the solution.

The warning message in the debug console is -

Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
      Using `ARCHS` setting to build architectures of target `Pods-RunnerTests`: (``)

    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 '10.27.0' defined in 'firebase_core'

    Resolving dependencies of `Podfile`

Error output from CocoaPods:
↳
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- ffi_c (LoadError)
        from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/ffi.rb:5:in `rescue in <top (required)>'
        from /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/ffi.rb:2:in `<top (required)>'
2
        from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'

...
...
...

from /usr/local/bin/pod:23:in `<main>'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h' or 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle' (no such file), '/Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h' or 'x86_64')) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle (LoadError)


...
...
...

from /usr/local/bin/pod:23:in `<main>'

Error running pod install
Error launching application on iPhone 12 Pro Max.

Exited (1).

I believe that there is some issue with how ruby is working with the arm64 and x86_64 archs in my system but I'm unable to figure out how to resolve the issue.

These are the things I tried after referring multiple documents and resources -

  1. Updated and flutter cocoapods -
flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec
flutter pub get
cd ios
pod install # (or on an M1+ mac: arch -x86_64 pod install)
cd ..
flutter build ios
flutter run
  1. Installed ffi in terminal for x86_64 architecture -
sudo arch -x86_64 gem install ffi
  1. Installed libffi using homebrew -
brew install libffi
gem install ffi
  1. Changed the iOS Platform in the Podfile of the Flutter project
platform :ios, '17.0'
  1. Install ruby 3.3.3 -
brew install [email protected] libyaml gmp readline

RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected]) --disable-install-doc" rbenv install 3.3.3

1 Answer 1

0

I had the same problem and managed to solve it using the tips posted here: https://github.com/CocoaPods/CocoaPods/issues/12440

The method that helped me was to uninstall CocoaPods using the command:

sudo gem uninstall cocoapods

and reinstalling using:

brew install cocoapods

You may need to install the Homebrew Package Manager first. After completing the operation, you may need to reopen the code editor so the path information is updated.

HTH

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.