Flutter iOS CocoaPods Not Installed Fix
In this tutorial, you'll learn about Flutter iOS CocoaPods Not Installed Fix. We cover key concepts, practical examples, and best practices.
Your Flutter iOS build fails with CocoaPods not installed, Pod install failed, or Unable to find a pod with name — CocoaPods is missing from your system or the pod dependencies cannot be resolved.
Step-by-Step Fix
1. Install CocoaPods
# Check if CocoaPods is installed
pod --version
# Wrong: using sudo gem install (may cause permission issues)
sudo gem install cocoapods
# Right: install via Homebrew (macOS)
brew install cocoapods
# Or install via gem with proper Ruby setup
gem install cocoapods
Expected output after installation:
1.15.2
2. Update the Podfile
# ios/Podfile
# Wrong: outdated platform version
platform :ios, '9.0'
# Right: use the minimum platform required by your Flutter version
platform :ios, '12.0'
# Use the new Flutter project structure
require File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
3. Fix pod conflicts
# Clean pod cache and reinstall
cd ios
# Remove existing Pods
rm -rf Pods/
rm -rf Podfile.lock
# Update the local CocoaPods spec repo
pod repo update
# Install pods
pod install --repo-update
Expected output:
Analyzing dependencies
Downloading dependencies
Installing Flutter (1.0.0)
Generating Pods project
Integrating client project
Pod installation complete! There are 3 dependencies from the Podfile and 3 total pods installed.
4. Fix Ruby environment issues
# Check current Ruby version
ruby --version
# Use the system Ruby (macOS)
# Wrong: using an incompatible Ruby version (3.3+ may have OpenSSL issues)
# Right: use the system Ruby that CocoaPods supports
# If using rbenv or rvm, switch to the correct version
rbenv global 3.1.0
# Reinstall CocoaPods after switching Ruby
gem uninstall cocoapods
gem install cocoapods
5. Handle M1/M2 Mac architecture issues
# For Apple Silicon Macs, install CocoaPods with the correct arch
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
# Or set the terminal to open with Rosetta
# Right-click Terminal -> Get Info -> Open using Rosetta
6. Set up the iOS project from scratch
# If the Pods directory is corrupted, regenerate everything
cd ..
flutter clean
rm -rf ios/Pods ios/Podfile.lock
cd ios && pod deintegrate && cd ..
flutter run
Prevention
- Run
pod --versionbefore starting a Flutter project to ensure CocoaPods is installed. - Keep CocoaPods updated:
gem update cocoapods. - Use the latest iOS platform version in your Podfile (
platform :ios, '12.0'). - After updating Flutter SDK, always run
pod repo update && pod install. - Add
ios/Pods/to.gitignore— never commit Pods to version control.
Common Mistakes with ios build error
- Mixing let bindings with <- bindings in do notation, producing type errors
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
These mistakes appear frequently in real-world FLUTTER code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro