Bidev

Flutter CocoaPods Error: Common Causes and Fixes

·4 min read·Intermediate

Running flutter build ios, flutter run on an iOS device/simulator, or pod install inside the ios/ directory fails with a CocoaPods dependency error.

Error
[!] CocoaPods could not find compatible versions for pod ...
iosflutterioscocoapodsxcode
Advertisement

The Problem

Running flutter build ios, flutter run on an iOS device/simulator, or pod install inside the ios/ directory fails with a CocoaPods dependency error.

Symptoms

  • Build fails during the 'Running pod install' step of a Flutter iOS build
  • Terminal shows [!] CocoaPods could not find compatible versions... or a similar resolution failure
  • Error may reference a specific pod, a deployment target mismatch, or a stale Podfile.lock

Why This Happens

  • CocoaPods itself is outdated relative to what the installed pods require
  • Two plugins/pods require incompatible versions of a shared dependency
  • The Podfile's platform :ios deployment target is lower than what a plugin requires
  • A stale Podfile.lock or Pods/ directory from before a Flutter/plugin upgrade
  • Xcode command line tools path is misconfigured, so CocoaPods can't find the right Xcode version

Quick Fix

From the ios/ directory, run `pod deintegrate && pod install` to fully reset CocoaPods' state — this resolves the majority of dependency-resolution errors caused by stale lock files.

How to Fix It

1. Update CocoaPods

sudo gem install cocoapods pod repo update An outdated CocoaPods version is a common source of resolution errors with newer plugins.

2. Clean and reinstall pods

cd ios pod deintegrate rm -rf Pods Podfile.lock pod install cd .. This removes all cached pod state and re-resolves dependencies from scratch.

3. Raise the deployment target in the Podfile

Open ios/Podfile and check the platform line: platform :ios, '13.0' If a plugin requires a higher iOS deployment target, raise it here and in Xcode's Runner target settings.

4. Read the actual conflicting pod names in the error

CocoaPods' resolution error lists exactly which pods conflict and why. Check each conflicting plugin's pubspec.yaml version against its changelog — one plugin often needs to be upgraded or downgraded to align with the others.
Advertisement

Common Mistakes

  • ×Opening Runner.xcodeproj instead of Runner.xcworkspace after CocoaPods is involved
  • ×Deleting Podfile.lock without running pod install afterward
  • ×Ignoring the deployment target requirement stated in a plugin's own documentation

How to Verify the Fix

  1. 1.Run flutter clean, then flutter build ios (or flutter run) again
  2. 2.Confirm pod install completes without errors and generates a fresh Podfile.lock
  3. 3.Open ios/Runner.xcworkspace (not .xcodeproj) in Xcode and confirm it builds
Share

Did this article save you time?

I write these for free. If it helped, a coffee keeps me going — and more articles coming.

Buy me a coffee

Comments

Comments

Leave a comment

0/2000

Comments appear after review.