Flutter
Mac
Pod Install
Error Solving
Troubleshooting

How to solve error running pod install in flutter on mac?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

The "error running pod install" in Flutter on macOS occurs when CocoaPods fails to install iOS dependencies for your Flutter project. Common causes include outdated CocoaPods, corrupted pod cache, incompatible Ruby versions, and missing Xcode command-line tools. The fix usually involves clearing the pod cache, updating CocoaPods, and ensuring your development environment is properly configured. This error blocks iOS builds but does not affect Android builds.

Fix 1: Clean and Reinstall Pods

bash
1# Navigate to the iOS directory
2cd ios
3
4# Remove existing pods and lockfile
5rm -rf Pods
6rm Podfile.lock
7
8# Go back to project root
9cd ..
10
11# Clean Flutter build cache
12flutter clean
13
14# Get dependencies and run pod install
15flutter pub get
16cd ios
17pod install
18cd ..
19
20# Build again
21flutter run

This is the most common fix. Removing Pods/ and Podfile.lock forces CocoaPods to resolve and download all dependencies from scratch.

Fix 2: Update CocoaPods

bash
1# Check current CocoaPods version
2pod --version
3
4# Update CocoaPods
5sudo gem install cocoapods
6
7# Or if using Homebrew
8brew upgrade cocoapods
9
10# Update the pod spec repository
11pod repo update
12
13# Now try again
14cd ios && pod install

Older versions of CocoaPods may not support newer pod specs. Updating CocoaPods resolves compatibility issues with recently published plugins.

Fix 3: Install Xcode Command-Line Tools

bash
1# Install command-line tools
2xcode-select --install
3
4# If already installed, verify the path
5xcode-select -p
6# Should output: /Applications/Xcode.app/Contents/Developer
7
8# If the path is wrong, reset it
9sudo xcode-select --reset
10
11# Accept Xcode license
12sudo xcodebuild -license accept

CocoaPods requires Xcode command-line tools for compiling native dependencies. If they are missing or pointing to the wrong Xcode installation, pod install fails.

Fix 4: Fix Ruby Issues

bash
1# Check Ruby version
2ruby --version
3
4# macOS Sonoma+ ships with Ruby removed — install via Homebrew
5brew install ruby
6
7# Add Homebrew Ruby to PATH
8echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
9source ~/.zshrc
10
11# Install CocoaPods with the new Ruby
12gem install cocoapods
13
14# If permission errors occur
15sudo gem install cocoapods
16# Or better — use gem user install
17gem install --user-install cocoapods

macOS Sonoma and later may not include Ruby by default. Install Ruby via Homebrew and then reinstall CocoaPods with the Homebrew Ruby.

Fix 5: Use pod deintegrate and Reinstall

bash
1# Install the deintegrate plugin
2sudo gem install cocoapods-deintegrate
3
4# Deintegrate pods completely
5cd ios
6pod deintegrate
7
8# Clean the project
9pod cache clean --all
10
11# Reinstall
12pod install --repo-update

pod deintegrate removes all CocoaPods integration from the Xcode project, giving you a clean slate. pod cache clean --all removes cached pod downloads that may be corrupted.

Fix 6: Apple Silicon (M1/M2/M3) Specific Fix

bash
1# Install ffi for arm64
2sudo arch -x86_64 gem install ffi
3
4# Or run pod install under Rosetta
5arch -x86_64 pod install
6
7# Better: install pods natively with arm64
8cd ios
9pod install
10
11# If that fails, try with the verbose flag to see the actual error
12pod install --verbose

On Apple Silicon Macs, some older native gems are not compiled for arm64. Running under Rosetta (arch -x86_64) or installing the ffi gem for x86_64 resolves these architecture mismatches.

Fix 7: Flutter Doctor

bash
1# Check your development environment
2flutter doctor -v
3
4# Expected output should show:
5# [✓] Flutter
6# [✓] Android toolchain
7# [✓] Xcode
8# [✓] CocoaPods
9
10# Fix any issues flutter doctor identifies
11# Common missing items:
12# - CocoaPods not installed
13# - Xcode not configured
14# - iOS simulator not available

flutter doctor -v diagnoses the entire development environment. Fix all issues it reports before attempting pod install again.

Fix 8: Podfile Platform Version

ruby
1# ios/Podfile
2# Ensure the minimum iOS version matches your plugins' requirements
3platform :ios, '13.0'  # Some plugins require 13.0+
4
5# If you see: "The platform of the target is not compatible"
6# Update this version to match the error message
bash
1# After updating the Podfile
2cd ios
3rm Podfile.lock
4pod install

Some Flutter plugins require a minimum iOS version higher than the project default. Update the platform line in Podfile to match the highest required version.

Fix 9: CDN Source Issues

ruby
1# ios/Podfile — replace the source if CDN is failing
2# Comment out the default CDN source
3# source 'https://cdn.cocoapods.org/'
4
5# Use the git source instead
6source 'https://github.com/CocoaPods/Specs.git'
bash
# Or update the CDN repo
pod repo update
pod install --repo-update

If CocoaPods fails to fetch specs from the CDN, switching to the git-based spec repo or running pod repo update resolves the issue.

Common Pitfalls

  • Running pod install from the wrong directory: pod install must be run from the ios/ directory, not the Flutter project root. Running it from the root causes "No Podfile found" errors.
  • Not running flutter pub get first: Flutter generates the ios/Podfile based on your pubspec.yaml dependencies. If you skip flutter pub get, the Podfile may be outdated or missing plugin entries.
  • Ignoring flutter clean: Stale build artifacts can cause pod install to fail with cryptic errors. Always run flutter clean before retrying pod install after making changes to dependencies.
  • CocoaPods version too old for Xcode version: Newer Xcode versions require recent CocoaPods releases. If you see "CDN: trunk" errors or xcframework issues, update CocoaPods to the latest version.
  • Modifying Podfile.lock manually: Never edit Podfile.lock by hand. If it becomes corrupted, delete it and run pod install to regenerate it.

Summary

  • Start with flutter clean, then rm -rf ios/Pods ios/Podfile.lock, then flutter pub get, then cd ios && pod install
  • Update CocoaPods with sudo gem install cocoapods if the version is outdated
  • Install Xcode command-line tools with xcode-select --install
  • On Apple Silicon, use arch -x86_64 pod install if native pod install fails
  • Run flutter doctor -v to check for environment issues
  • Set the correct platform :ios version in Podfile to match plugin requirements

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.