Fixing the "Unable to Find Compatibility Version String" Error in iOS Pod Install
How to fix Unable to Find Compatibility Version String
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
-
Locate the File:
Right-click your.xcodeprojfile in Finder, select "Show Package Contents", and open theproject.pbxprojfile in a text editor. -
Edit the Object Version:
Find the line:- objectVersion = 70;And change it to:
+ objectVersion = 77; -
Save the File:
With the updated version, runpod installagain.
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 installcommand fails because the project'sobjectVersionis set to70, which thexcodeprojgem doesn't recognize. - Workaround: I initially patched the gem by adding a mapping (
70 => 'Xcode 16.2'). - Proper Fix: Update your project's
project.pbxprojfile to change theobjectVersionfrom70to77, matching the configuration of Xcode 16.2 projects.
This solution avoids modifying gem files, ensuring your development environment remains stable across projects.
Happy coding!