Getting error while run flutter app in iOS - flutter

Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running pod install...
CocoaPods' output:
↳
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
Error output from CocoaPods:
↳
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/unicode_normalize/normalize.rb:141:in `normalize': Unicode Normalization not appropriate for ASCII-8BIT (Encoding::CompatibilityError)
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/config.rb:166:in `unicode_normalize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/config.rb:166:in `installation_root'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/config.rb:226:in `podfile_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/user_interface/error_report.rb:105:in `markdown_podfile'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/user_interface/error_report.rb:30:in `report'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command.rb:66:in `report_error'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:396:in `handle_exception'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:337:in `rescue in run'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:324:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command.rb:52:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/unicode_normalize/normalize.rb:141:in `normalize': Unicode Normalization not appropriate for ASCII-8BIT (Encoding::CompatibilityError)
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/config.rb:166:in `unicode_normalize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/config.rb:166:in `installation_root'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/config.rb:226:in `podfile_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/config.rb:205:in `podfile'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command.rb:160:in `verify_podfile_exists!'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command/install.rb:46:in `run'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command.rb:52:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
Error running pod install
Error launching application on iPhone 12 Pro Max.

It seems that is a sort of bug/incombatibility issue in Cocoapods v 1.11.0
To fix the issue, I followed these steps and it worked like a charm: https://stackoverflow.com/a/69076515/16881741
Briefly, follow these steps:
In your terminal, in ios folder type
gem list --local | grep cocoapods
Take note of what is the output of the previous command. It looks like that (please ignore the version near the various entry, this is my output and I already use the version 1.10.1):
cocoapods (1.10.1)
cocoapods-core (1.10.1)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.5.1)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
cocoapods-try (1.2.0)
One by one, launch the command
sudo gem uninstall X
substituting the "X" with the name of the cocoapods component, without the version.
At the end you should obtain this:
sudo gem uninstall cocoapods
sudo gem uninstall cocoapods-core
sudo gem uninstall cocoapods-deintegrate
sudo gem uninstall cocoapods-downloader
sudo gem uninstall cocoapods-plugins
sudo gem uninstall cocoapods-search
sudo gem uninstall cocoapods-trunk
sudo gem uninstall cocoapods-try
Be sure to have included all the component listed in the point n.1 to avoid dirty status
Use the command
sudo gem install cocoapods -v 1.10.1
To obtain the correct version.
All kudos to Esteban Lopez, the author of the answer I linked at the top.

This issues appeared in Cocoapods 1.11.0 and as many already noticed rolling back to 1.10.2 fixes the issue. But the original issue comes from wrong locale set in the terminal. It has to be a UTF-8-based locale.
The second answer in here solved the issue for me.
As stated, just run
export LC_ALL=en_US.UTF-8
in your terminal, and the error should go away. Consider adding this to your .zshrc file so that it happens automatically in every session.

This worked for me:
flutter clean,
delete /iOS/Pods,
delete /iOS/Podfile.lock,
flutter build ios.
my Mac version info:
CocoaPods : 1.11.0
Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
RubyGems : 3.0.3
Host : macOS 11.5.2 (20G95)
Xcode : 12.5.1 (12E507)
Git : git version 2.23.0
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Ran the same project on VCode and it worked successfully, guess the issue was with my Android Studio.

Upgrade Ruby is another way to resolve this issue.

Try pod install with default terminal.

Related

Why does Installing Cocoapods gives File Permission Error

I am trying to install cocoapods on my MacBook Pro (Retina, 15-inch, Mid 2015) running a mac-os of Monterey version 12.6.1 using $ sudo gem install cocoapods on the terminal but it gives the following error.
apple#APPLEs-MBP ~ % sudo gem install cocoapods
Password:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
/Library/Ruby/Site/2.6.0/rubygems/installer.rb:712:in `verify_gem_home'
/Library/Ruby/Site/2.6.0/rubygems/installer.rb:902:in `pre_install_checks'
/Library/Ruby/Site/2.6.0/rubygems/installer.rb:302:in `install'
/Library/Ruby/Site/2.6.0/rubygems/resolver/specification.rb:104:in `install'
/Library/Ruby/Site/2.6.0/rubygems/request_set.rb:194:in `block in install'
/Library/Ruby/Site/2.6.0/rubygems/request_set.rb:182:in `each'
/Library/Ruby/Site/2.6.0/rubygems/request_set.rb:182:in `install'
/Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:210:in `install_gem'
/Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:226:in `block in install_gems'
/Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:219:in `each'
/Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:219:in `install_gems'
/Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:167:in `execute'
/Library/Ruby/Site/2.6.0/rubygems/command.rb:323:in `invoke_with_build_args'
/Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:185:in `process_args'
/Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:149:in `run'
/Library/Ruby/Site/2.6.0/rubygems/gem_runner.rb:51:in `run'
/usr/bin/gem:21:in `<main>'
apple#APPLEs-MBP ~ %
I am Using Xcode 14.1 (14b47b) and I also checked that the command line tools is also present and using a similar version. I have tried to install via Homebrew but when following the instruction at some point it ask me to install command line tools again. I still do this despite having the most recent version installed and after complete download it just do nothing. I have tried this process more than 10 times already.
When i use this code sudo gem update --system it says latest version already installed. I have tried everything on stack-overflow it still will not work.
I have finally resolved the error and I am posting the processes used incase someone faces the exact same issue.
Firstly I ran % ruby -v and % which ruby with terminal and took note of my ruby version and path (This was the default Mac ruby).
I downloaded Command line tools version 14.1 from https://developer.apple.com This version was the same version as my xcode and it was already installed with xcode but I download and installed anyway.
After the successful installation of the Command line tool, I moved on to download Hombrew and after the install was successful, I then installed the cocoapods using % brew install cocoapods in terminal. At this point point cocoapods was installed but not properly working. as it was giving an error about 40 gems and some manifest not found.
This prompt me to install ruby with % brew install ruby and after taking some time it was installed successfully with some instructions on how to change the default ruby to the newly installed ruby. The instructions where to run the following code in terminal.
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc $ echo 'export LDFLAGS="-L/usr/local/opt/ruby/lib"' >> ~/.zshrc $ echo 'export CPPFLAGS="-I/usr/local/opt/ruby/include"' >> ~/.zshrc $ source ~/.zshrc
After doing step 4, run % ruby -v and % which ruby and you will see that your ruby path and ruby version has been changed.
Lastly I then installed Cocoapods using this % sudo gem install -n /usr/local/bin cocoapods and it was all installed successfuly.

`require': cannot load such file -- 2.6/ffi_c (LoadError) while running Flutter project on an M1

I'm getting the following issue while running a flutter project on a M1 Mac.
/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 -- 2.6/ffi_c (LoadError)
I have tried uninstalling and installing the ffi gem as suggested in the Flutter docs.
The issue is still showing.
Found a workaround, still need to investigate if this is the appropriate solution. Run the following in your terminal to install the x86 gem.
arch -x86_64 sudo gem install ffi

Unable to rebuild flutter app after setting up Firebase

When attempting "flutter run" from step 3.5 of the official "Add Firebase to your app" tutorial with the standard flutter starter app (So as to limit other potential issues) (See https://firebase.google.com/docs/flutter/setup?authuser=0&hl=en&platform=ios), I get the following output in the debug console:
{ from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in section' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in resolve_dependencies'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in install!' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in run'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in run' from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in <top (required)>' from /usr/local/bin/pod:23:in load'
from /usr/local/bin/pod:23:in `'
Error: To set up CocoaPods for ARM macOS, run:
arch -x86_64 sudo gem install ffi
Error running pod install
Error launching application on iPhone 12.
Exited}
And then when I run the suggested:
{arch -x86_64 sudo gem install ffi}
It appears to run successfully, printing:
{Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Parsing documentation for ffi-1.15.5
Done installing documentation for ffi after 3 seconds
1 gem installed}
But if I then re-run "flutter run", I get exactly the same error as before.
I've tried flutter clean, uninstalling and reinstalling the -x86_64 versions of both ffi and cocoapods but still keep getting the same error...
Any ideas?
Managed to solve this by running arch -x86_64 pod install from the /ios folder.
Try this:
Delete Podfile.lock file in the iOS folder of your flutter project.
Run in terminal from the root of your project in iOS folder:
arch -x86_64 sudo gem install ffi and then arch -x86_64 pod install.
Clean your project in XCode using Shift+command+Key.
Now try to build the project again.

Problem while running pod init: "Ignoring ffi-1.15.0 because its extensions are not built."

While running pod init on my Xcode Project, I come across a problem in the terminal with the following message:
Ignoring ffi-1.15.0 because its extensions are not built. Try: gem pristine ffi --version 1.15.0
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:128:in `git_version': Failed to extract git version from `git --version` ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun\n") (RuntimeError)
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:140:in `verify_minimum_git_version!'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:49:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
"
I've tried running gem pristine ffi --version 1.15.0" and that gives me the following
message: "Ignoring ffi-1.15.0 because its extensions are not built. Try: gem pristine ffi --version 1.15.0
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
If you have any suggestions please let me know, thanks.

Error while installing pod in Apple Silicon (M1)

Command i am running is
brew install cocoapods
Warning: cocoapods 1.11.2_2 is already installed and up-to-date.
To reinstall 1.11.2_2, run:
brew reinstall cocoapods
~ % alias pod='arch -x86_64 pod'
Below is error :
/opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver/conflict.rb:47:in `conflicting_dependencies': undefined method `request' for nil:NilClass (NoMethodError)
[#failed_dep.dependency, #activated.request.dependency]
^^^^^^^^
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/exceptions.rb:61:in `conflicting_dependencies'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/exceptions.rb:55:in `initialize'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver.rb:193:in `exception'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver.rb:193:in `raise'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver.rb:193:in `rescue in resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver.rb:191:in `resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/request_set.rb:411:in `resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/request_set.rb:423:in `resolve_current'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems.rb:230:in `finish_resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems.rb:287:in `block in activate_bin_path'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems.rb:285:in `synchronize'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems.rb:285:in `activate_bin_path'
from /opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/bin/pod:25:in `<main>'
/opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:317:in `raise_error_unless_state': Unable to satisfy the following requirements: (Gem::Resolver::Molinillo::VersionConflict)
- `minitest (= 5.14.2)` required by `user-specified dependency`
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:299:in `block in unwind_for_conflict'
from <internal:kernel>:90:in `tap'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:297:in `unwind_for_conflict'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:682:in `attempt_to_activate'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:254:in `process_topmost_state'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:182:in `resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver/molinillo/lib/molinillo/resolver.rb:43:in `resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/resolver.rb:190:in `resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/request_set.rb:411:in `resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems/request_set.rb:423:in `resolve_current'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems.rb:230:in `finish_resolve'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems.rb:287:in `block in activate_bin_path'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems.rb:285:in `synchronize'
from /opt/homebrew/Cellar/ruby/3.1.1/lib/ruby/3.1.0/rubygems.rb:285:in `activate_bin_path'
from /opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/bin/pod:25:in `<main>'
I Uninstall and install RUBY and COCOPODS again.
and now below is the error :
/Library/Ruby/Site/2.6.0/rubygems.rb:265:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.6.0/rubygems.rb:284:in `activate_bin_path'
from /usr/local/bin/pod:23:in `<main>'
I solved this by removing cocoapod and installing it again
gem cleanup
brew uninstall cocoapods
sudo gem uninstall cocoapods
sudo gem install cocoapods -n /usr/local/bin
sudo gem install cocoapods-user-defined-build-types
pod install --repo-update
I was having this same issue when running pod install, NOT during the installation of Cocoapods. This GitHub comment helped me solve it. I was using ruby 3.0.0. I installed 3.0.3, followed by Cocoapods, and then pod install started working.
I ran into the same error. I'm using rvm (RubyVersionManager). Make sure that you're using the same version of Ruby as when you first ran the install. If you're running the install for the first time, make sure that you're not using the system version of Ruby (It's a very old version).
In my case, I was trying to run pod install on version 3.0.0, but I should've been running it on 3.1.2, changing my version fixed the issue.
Try deleting your yarn.lock or package.lock file. hopefully, that works.
if that doesn't work, try rvm install ruby-3.1.1 rvm --default use ruby-3.1.1
Cocoa-pods Install in M1
I use HomeBrew https://brew.sh/
Here how its works.
Copy & Run this command in terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
If you get any warning like(Warning: /opt/homebrew/bin is not in your PATH.
Instructions on how to configure your shell for Homebrew
can be found in the 'Next steps' section below.)
then please ignore these two commands.
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/shourob.datta/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Now Install Cocoapods
brew install cocoapods
Now Install pods, locate the project
Pod install
DONE