Flutter Cocoapods Ruby Mess
Background
I have been working on the wwm app for a month now. Everything has been going on seamlessly, the development, althought not super fast, was brisk. I have been making a pull request almost every week. Until last week; Saturday. I woke up in the morning, went to the coffee shop with Nammi to work, tried to pull up the ios simulator to run the app and well, nothing comes up! The issue was: You seem to have cocoapods installed but not working.
Fix
Let’s just say I spent a lot of time fixing what was indeed the issue. After numerous links, stackoverflow, giothib issues, reddit; here was the issue:
- MacOS Sonoma uses ruby 2.6, which is something you really do not wanna touch
- New Flutter versions and all that needs new versions of ruby and cocoapods. Newest stable version of Ruby is 3.0.0
- You have to make sure your default version of ruby is 3.0.0 or whatever you want to upgrade it, not the default one that Mac’s using
- Use rvm to install the new version of ruby, make it default. Otherwise your project will always go back to using the 2.6.whatever mac’s using. Make sure to install rvm (or any other ruby version manager). Also make sure to install with your openssl. which openssl should give you the folder for openssl. Use that to rvm install 3.0.0 –with-openssl-dir=$dir-to-openssl
- Then install cocapods for that ruby version
- Flutter doctor should work after that.
Another issue
If after all that, you are getting the following errors:
- flutter Unable to find a target named
RunnerTests
in projectRunner.xcodeproj
, did findRunner
. - Flutter Automatically assigning platform
iOS
with version12.0
on targetRunner
because no platform was specified. Please specify a platform for this target in your Podfile. Seehttps://guides.cocoapods.org/syntax/podfile.html#platform
Fix
In the ios folder, delete the podfile, the pod lock file. Then rerun. If the issue persists, then do the following:
- uncomment the ios version line in the podfile
- uncomment these lines in the podfile:
target 'RunnerTests' do inherit! :search_paths end
That should do the trick!