You’ve probably tried upgrading major versions before, if you haven’t I recommend you do it as soon as you can. Upgrading both libraries and frameworks frequently will save you loads of time compared to letting it pile up. Also, you get the benefits of any performance and bug fixes at the same time and if there are any issues, you’ll find and fix them sooner rather than at a critical time when your release must succeed.
So when I was fixing some issues on my app, JReader I decided to also upgrade to the latest Flutter 2. All in all, there were very few breaking changes.
But I did have an issue as I tried building it on iOS. I haven’t seen this before using the same Ruby version and Cocoapods version as I have now so I believe this came with the upgrade.
I was running
- Ruby 2.5.0
- Flutter stable 2.0.1
- Cocoapods 1.10.1
And this is the error I got:
[!] An error occurred while processing the post-install hook of the Podfile.
undefined method `each_child' for #<Dir:0x00007fcc04b82ef0>
Did you mean? each_slice
/Users/ddikman/flutter/packages/flutter_tools/bin/podhelper.rb:54:in `block in flutter_additional_ios_build_settings'
/Users/ddikman/flutter/packages/flutter_tools/bin/podhelper.rb:51:in `each'
/Users/ddikman/flutter/packages/flutter_tools/bin/podhelper.rb:51:in `flutter_additional_ios_build_settings'
/Users/ddikman/code/jreader/ios/Podfile:41:in `block (3 levels) in from_ruby'
/Users/ddikman/code/jreader/ios/Podfile:40:in `each'
/Users/ddikman/code/jreader/ios/Podfile:40:in `block (2 levels) in from_ruby'
/Users/ddikman/.rvm/gems/ruby-2.5.8/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:179:in `post_install!'
/Users/ddikman/.rvm/gems/ruby-2.5.8/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:897:in `run_podfile_post_install_hook'
/Users/ddikman/.rvm/gems/ruby-2.5.8/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:885:in `block in run_podfile_post_install_hooks'
/Users/ddikman/.rvm/gems/ruby-2.5.8/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:145:in `message'
/Users/ddikman/.rvm/gems/ruby-2.5.8/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:884:in `run_podfile_post_install_hooks'
/Users/ddikman/.rvm/gems/ruby-2.5.8/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:329:in `block (2 levels) in create_and_save_projects'
/Users/ddikman/.rvm/gems/ruby-2.5.8/gems/cocoapods-1.10.1/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
I found only one or two hits on this issue, one from a Japanese post (luckily my app is for practicing Japanese so this came quite in handy) and one answer on stackoverflow.
According to the docs, this change was introduced in Ruby 2.5 and even updating to 2.5.8 in RVM I got no luck.
Finally, I upgraded to 2.7.1, set it as default and reinstalled cocopods, restarted Android studio and finally it was building!
Here are the final steps (and see here on using RVM):
rvm list # check current version
rvm install 2.7.1
rvm --default use 2.7.1
gem install cocoapods
pod --version
Hope it helps!