Cocoapods: Unknown object version -- 53

Created on 22 May 2020  路  8Comments  路  Source: CocoaPods/CocoaPods

I am using CocoaPods 1.9.2 (and Flutter 1.17.1).

Report

What did you do?

I have a ios/Runner.xcodeproj/project.pbxproj file with an objectVersion = 53; -- this was written by XCode.

pod update reports Unknown object version.

RuntimeError - [Xcodeproj] Unknown object version.
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.15.0/lib/xcodeproj/project.rb:227:in `initialize_from_file'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.15.0/lib/xcodeproj/project.rb:112:in `open'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer/analyzer.rb:1177:in `block (2 levels) in inspect_targets_to_integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer/analyzer.rb:1176:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer/analyzer.rb:1176:in `block in inspect_targets_to_integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer/analyzer.rb:1171:in `inspect_targets_to_integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer/analyzer.rb:106:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer.rb:410:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer.rb:235:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer.rb:234:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/installer.rb:156:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/command/update.rb:63:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

What did you expect to happen?

I did not expect a _Runtime Error_.

What happened instead?

pod is broken.

A workaround is to hack the objectVersion -- changing from 53 to 52 does the trick. However, then pod makes a few other changes to the file that make me uncomfortable. Here is the diff:

diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 0f4a643..5c5ced2 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
        archiveVersion = 1;
        classes = {
        };
-       objectVersion = 53;
+       objectVersion = 52;
        objects = {

 /* Begin PBXBuildFile section */
@@ -231,10 +231,10 @@
                        buildActionMask = 2147483647;
                        files = (
                        );
-                       inputPaths = (
+                       inputFileListPaths = (
                        );
                        name = "[CP] Embed Pods Frameworks";
-                       outputPaths = (
+                       outputFileListPaths = (
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
@@ -314,10 +314,10 @@
                        buildActionMask = 2147483647;
                        files = (
                        );
-                       inputPaths = (
+                       inputFileListPaths = (
                        );
                        name = "[CP] Copy Pods Resources";
-                       outputPaths = (
+                       outputFileListPaths = (
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;

(_Is it normal for pod to rewrite this file?_ I would have guessed that it was read-only, and only XCode should modify it.)

CocoaPods Environment

Stack

   CocoaPods : 1.9.2
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
    RubyGems : 3.0.3
        Host : Mac OS X 10.15.4 (19E287)
       Xcode : 11.5 (11E608c)
         Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : master - git - https://github.com/CocoaPods/Specs.git @ 7a2a87b70aac3e71c0002b6ae4d4b6dc6090ae81

               trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '10.1'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  generated_key_values = {}
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) do |line|
    next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
    plugin = line.split(pattern=separator)
    if plugin.length == 2
      podname = plugin[0].strip()
      path = plugin[1].strip()
      podpath = File.expand_path("#{path}", file_abs_path)
      generated_key_values[podname] = podpath
    else
      puts "Invalid plugin specification: #{line}"
    end
  end
  generated_key_values
end

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  # Flutter Pod

  copied_flutter_dir = File.join(__dir__, 'Flutter')
  copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
    # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
    # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
    # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

    generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
    unless File.exist?(generated_xcode_build_settings_path)
      raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
    end
    generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
    cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

    unless File.exist?(copied_framework_path)
      FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
    end
    unless File.exist?(copied_podspec_path)
      FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
    end
  end

  # Keep pod path relative so it can be checked into Podfile.lock.
  pod 'Flutter', :path => 'Flutter'

  # Plugin Pods

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.each do |name, path|
    symlink = File.join('.symlinks', 'plugins', name)
    File.symlink(path, symlink)
    pod name, :path => File.join(symlink, 'ios')
  end
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end
defect

Most helpful comment

I believe this is already resolved. gem update xcodeproj to 1.16.

All 8 comments

Yep thanks, need to add this for Xcode 11.5 which was released this week

I believe this is already resolved. gem update xcodeproj to 1.16.

@dnkoutso 1.16 added Xcode 11.4, not 11.5

OH but it is that object version. my mistake

For what it is worth, I had this issue before XCode 11.5 was released. (This may be 11.4 related.)

I just updated xcodeproj to 1.16 and now it works! 馃帀 @dnkoutso Thank you! Does that dependency not get updated when upgrading cocoapods?

It still rewrites the file changing some fields like inputPaths to inputFileListPaths, and outputPaths to outputFileListPaths -- is that expected?

Yes its expected since your project version supports xcfilelists.

We dont always bump minimum versions of gem dependencies to avoid tight coupling. Only when cocoapods uses a new API we bump minimum version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mingmingmew picture Mingmingmew  路  3Comments

tlandsmancars picture tlandsmancars  路  3Comments

spencerkohan picture spencerkohan  路  3Comments

iosdev-republicofapps picture iosdev-republicofapps  路  3Comments

pronebird picture pronebird  路  3Comments