Skip to content

CocoaPods Dependency Resolution Issues in Flutter iOS

When working with Flutter projects that include iOS-specific dependencies, you might encounter CocoaPods compatibility issues that prevent your app from building. This comprehensive guide covers the most effective solutions for resolving dependency conflicts and getting your Flutter iOS project running smoothly.

Problem Statement

The core issue occurs when CocoaPods cannot find compatible versions for required dependencies, typically showing errors like:

CocoaPods could not find compatible versions for pod "GoogleDataTransport"

This happens because:

  • Your local CocoaPods repository is outdated
  • There are conflicts between dependency versions in your Podfile.lock
  • The Flutter plugin versions require specific iOS SDK versions that aren't available locally
  • Platform version specifications in your Podfile are missing or incorrect

Solutions

Standard Solution (Works for most cases)

bash
# Clean the Flutter build
flutter clean

# Remove iOS-specific dependency files
rm -rf ios/Pods
rm ios/Podfile.lock

# Get Flutter dependencies
flutter pub get

# Navigate to iOS directory and install pods
cd ios
pod install --repo-update
cd ..

# Run your app
flutter run

TIP

Using pod install --repo-update ensures CocoaPods updates its repository before attempting to resolve dependencies, which often fixes version compatibility issues.

Alternative Approaches

For M1/M2 Mac Users

Apple Silicon Macs may require additional steps due to architecture differences:

bash
# Install ffi for architecture compatibility
sudo arch -x86_64 gem install ffi

# Update CocoaPods repository with architecture specification
arch -x86_64 pod repo update

# Install pods with architecture specification
arch -x86_64 pod install --repo-update

Complete Clean Reinstall

If the standard solution doesn't work, try a more thorough approach:

bash
# Remove trunk repository and completely refresh
pod repo remove trunk

# Follow with the standard solution steps
flutter clean
rm -rf ios/Pods
rm ios/Podfile.lock
flutter pub get
cd ios
pod install --repo-update
cd ..
flutter run

Fixing Platform Version Issues

If you encounter errors regarding minimum deployment targets:

  1. Open ios/Podfile in your text editor
  2. Find the platform line (usually around line 2)
  3. Ensure it specifies a modern iOS version:
ruby
platform :ios, '12.0' # or higher based on your requirements

WARNING

Some Firebase and other third-party services require minimum iOS deployment targets of 11.0 or higher. Check the documentation for your specific dependencies.

Prevention Best Practices

To avoid future CocoaPods dependency issues:

  1. Regularly update your CocoaPods installation:

    bash
    sudo gem install cocoapods
  2. Keep Flutter updated:

    bash
    flutter upgrade
  3. Run repo updates periodically:

    bash
    pod repo update
  4. Commit Podfile.lock to version control to maintain consistent dependency versions across your team

When to Use Specific Solutions

ScenarioRecommended Approach
First-time project setupStandard solution
After adding new pluginspod install --repo-update
Switching Flutter versionsComplete clean reinstall
M1/M2 Mac build issuesArchitecture-specific commands
Firebase version conflictsCheck platform version in Podfile

Troubleshooting Common Errors

If you continue to experience issues:

  1. Check your Flutter and Dart versions are compatible with your dependencies
  2. Verify CocoaPods version with pod --version (latest is recommended)
  3. Examine specific dependency conflicts in the error message and check if you need to update specific plugins
  4. Consult plugin documentation for any iOS-specific setup requirements

DANGER

Avoid deleting your entire iOS directory as this will remove important configuration files and Xcode project settings. Only remove the Pods directory and Podfile.lock when troubleshooting CocoaPods issues.

By following these structured approaches, you should be able to resolve most CocoaPods dependency issues in your Flutter iOS projects and maintain a stable development environment.