Fixing the "Unable to Find Compatibility Version String" Error in iOS Pod Install

How to fix Unable to Find Compatibility Version String

Fixing the "Unable to Find Compatibility Version String" Error in iOS Pod Install

When running pod install for my iOS project, I encountered the following error:

/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.27.0/lib/xcodeproj/project.rb:85:in initialize': [Xcodeproj] Unable to find compatibility version string for object version `70. (ArgumentError)

What Went Wrong?

The error was caused by an unexpected objectVersion value in your project's project.pbxproj file:

- objectVersion = 70;

The xcodeproj gem did not recognize this version, as it expects a mapping for known version values (for example, newer Xcode projects use a different value).

My Initial Workaround: Patching the Gem

Initially, I patched the gem by modifying the file:

/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.27.0/lib/xcodeproj/constants.rb

I added a mapping for version 70:

70 => 'Xcode 16.2',

This allowed pod install to run successfully. However, modifying gem files isn't ideal because it may lead to issues in other projects or when updating gems.

The Final and Better Solution: Update Your Xcode Project

I discovered that when creating a new empty project with Xcode 16.2, the generated project.pbxproj file contains:

+ objectVersion = 77;

Therefore, the proper solution is to update your existing project's project.pbxproj file.

How to Update the project.pbxproj File

  1. Locate the File:
    Right-click your .xcodeproj file in Finder, select "Show Package Contents", and open the project.pbxproj file in a text editor.

  2. Edit the Object Version:
    Find the line:

    - objectVersion = 70;
    

    And change it to:

    + objectVersion = 77;
    
  3. Save the File:
    With the updated version, run pod install again.

Alternative: Using the Terminal

If you prefer the command line, you can run the following command (replace MyProject.xcodeproj with your project's name):

sed -i '' 's/objectVersion = 70/objectVersion = 77/' MyProject.xcodeproj/project.pbxproj

Summary

  • Error: The pod install command fails because the project's objectVersion is set to 70, which the xcodeproj gem doesn't recognize.
  • Workaround: I initially patched the gem by adding a mapping (70 => 'Xcode 16.2').
  • Proper Fix: Update your project's project.pbxproj file to change the objectVersion from 70 to 77, matching the configuration of Xcode 16.2 projects.

This solution avoids modifying gem files, ensuring your development environment remains stable across projects.

Happy coding!