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 installError 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 installError 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 -
- Updated and flutter cocoapods -
flutter cleanrm -Rf ios/Podsrm -Rf ios/.symlinksrm -Rf ios/Flutter/Flutter.frameworkrm -Rf ios/Flutter/Flutter.podspecflutter pub getcd iospod install # (or on an M1+ mac: arch -x86_64 pod install)cd ..flutter build iosflutter run
- Installed
ffi
in terminal for x86_64 architecture -
sudo arch -x86_64 gem install ffi
- Installed
libffi
using homebrew -
brew install libffigem install ffi
- Changed the iOS Platform in the Podfile of the Flutter project
platform :ios, '17.0'
- Install ruby 3.3.3 -
brew install openssl@1.1 libyaml gmp readlineRUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1) --disable-install-doc" rbenv install 3.3.3