一:Xcode 16 使用 pod 命令報錯解決方案

一、問題現(xiàn)象:

有人會遇到 Xcode 升級到 16 后,新建應(yīng)用然后使用 pod init命令會報錯如下:

1,報錯簡介信息如下:

RuntimeError - `PBXGroup` attempted to initialize an object with unknown ISA `PBXFileSystemSynchronizedRootGroup` from attributes: `{"isa"=>"PBXFileSystemSynchronizedRootGroup", "exceptions"=>["3A838D4F2CA3ED7800EBAD00"], "explicitFileTypes"=>{}, "explicitFolders"=>[], "path"=>"ShareFileds", "sourceTree"=>"<group>"}`
If this ISA was generated by Xcode please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/x

2,報錯詳情信息如下:

[!] The version of CocoaPods used to generate the lockfile (1.16.2) is higher than the version of the current executable (1.15.2). Incompatibility issues may arise.

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

### Command

/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/bin/pod install

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?


### Stack

   CocoaPods : 1.15.2
        Ruby : ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin23]
    RubyGems : 3.5.18
        Host : macOS 15.3.1 (24D70)
       Xcode : 16.2 (16C5032a)
         Git : git version 2.45.1
Ruby lib dir : /opt/homebrew/Cellar/ruby/3.3.5/lib
Repositories : cocoapods - git - https://github.com/CocoaPods/Specs.git @ 5d58e0ae26580bf632f9ae9310c26dca6182033f

               trunk - CDN - https://cdn.cocoapods.org/
               tsinghua-git-cocoapods - git - https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git @ fd83e41c482dc99f51554d60a0ee207697a6b6fb

### Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0

### Podfile

ruby
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
source 'https://github.com/CocoaPods/Specs.git'
# flutter_application_path 是flutter 工程的項目路徑
flutter_application_path = '../SSB-Flutter/flutter_project'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
post_install do |installer|
  flutter_post_install(installer) if defined?(flutter_post_install)
end

target 'SSBApp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
 use_frameworks!
 # 這邊引入
 install_all_flutter_pods(flutter_application_path)

 pod 'YYCache', '~> 1.0.4'
 pod 'AFNetworking', '~> 4.0.1'
 pod 'FMDB','~> 2.7.5'
 pod 'Reachability', '~> 3.2'
 pod 'XMPPFramework', '~> 3.7.0'
 pod 'MJExtension', '~> 3.0.17'
 pod 'IGListKit','~> 3.4.0'
 pod 'SDWebImage', '~> 5.0.3'
 pod 'Masonry', '~> 1.1.0'
 pod 'MJRefresh', '~> 3.0.8'
 pod 'MBProgressHUD', '~> 0.9.1'
 pod 'FWPopupViewOC','~>3.0.4'
 pod 'DGActivityIndicatorView'
 pod 'SocketRocket', '~> 0.6.0'
 pod 'SBJson', '~> 4.0.2'
# pod 'UMCCommon','~> 2.1.1'
# pod 'UMCAnalytics','~> 6.0.5'
 pod 'SwiftyJSON', '~> 4.3.0'
 pod 'YYImage'
 pod 'SSZipArchive'
 pod 'YYCategories'
 pod 'YYModel'
 pod 'CocoaAsyncSocket'
# pod 'Bugly', '~> 2.6.1'
 
#  pod 'SocketIO'
#  pod 'Starscream', '~> 4.0.6'
 
end

#def update_xcconfig(xcconfig_path, key, value)
#  # read from xcconfig to build_settings dictionary
#  build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.delete!("\n").split(/\s*=\s*/, 2)}.flatten]
#  
#  # modify key
#  if build_settings.has_key?(key)
#    if build_settings[key].index(value) == nil
#      build_settings[key] << value
#    end
#  else
#    build_settings[key] = value
#  end
#  
#  # write build_settings dictionary to xcconfig
#  File.open(xcconfig_path, "w+") {|file|
#    build_settings.each do |k, v|
#      file.puts "#{k} = #{v}"
#    end
#  }
#end
#
## post_install hook
#post_install do |installer|
#  installer.pods_project.targets.each do |target|
#    target.build_configurations.each do |config|
#      xcconfig_path = config.base_configuration_reference.real_path
#      update_xcconfig(xcconfig_path, 'OTHER_LDFLAGS', ' -Wl,-weak-lswiftCoreGraphics')
#    end
#  end
#end

### Error

RuntimeError - `PBXGroup` attempted to initialize an object with unknown ISA `PBXFileSystemSynchronizedRootGroup` from attributes: `{"isa"=>"PBXFileSystemSynchronizedRootGroup", "exceptions"=>["3A838D4F2CA3ED7800EBAD00"], "explicitFileTypes"=>{}, "explicitFolders"=>[], "path"=>"ShareFileds", "sourceTree"=>"<group>"}`
If this ISA was generated by Xcode please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:359:in `rescue in object_with_uuid'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:349:in `object_with_uuid'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:300:in `block (2 levels) in configure_with_plist'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:299:in `each'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:299:in `block in configure_with_plist'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:296:in `each'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:296:in `configure_with_plist'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project.rb:272:in `new_from_plist'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:350:in `object_with_uuid'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:290:in `block in configure_with_plist'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:287:in `each'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:287:in `configure_with_plist'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project.rb:272:in `new_from_plist'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project.rb:213:in `initialize_from_file'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project.rb:113:in `open'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1194:in `block (2 levels) in inspect_targets_to_integrate'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1193:in `each'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1193:in `block in inspect_targets_to_integrate'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1188:in `inspect_targets_to_integrate'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:107:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:422:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:162:in `install!'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/bin/pod:25:in `<main>'
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=%60PBXGroup%60+attempted+to+initialize+an+object+with+unknown+ISA+%60PBXFileSystemSynchronizedRootGroup%60+from+attributes%3A+%60%7B%22isa%22%3D%3E%22PBXFileSystemSynchronizedRootGroup%22%2C+%22exceptions%22%3D%3E%5B%223A838D4F2CA3ED7800EBAD00%22%5D%2C+%22explicitFileTypes%22%3D%3E%7B%7D%2C+%22explicitFolders%22%3D%3E%5B%5D%2C+%22path%22%3D%3E%22ShareFileds%22%2C+%22sourceTree%22%3D%3E%22%3Cgroup%3E%22%7D%60%0AIf+this+ISA+was+generated+by+Xcode+please+file+an+issue%3A+https%3A%2F%2Fgithub.com%2FCocoaPods%2FXcodeproj%2Fissues%2Fnew&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...
Searching for inspections failed: undefined method `map' for nil

二、解決方案

第一步,打開工程,如下:


image.png

打開工程程序 - 選中左側(cè) - 所有藍(lán)色文件夾?? - 單個點擊每個藍(lán)色文件夾?? - 右鍵選擇 Convert to Group。選擇Convert to Group完成后,文件夾會變成灰色,如上圖,就是處理完成后的效果。

注:
①. 所有藍(lán)色的文件夾??,單個點擊開都需要右鍵選擇 Convert to Group。
②. 灰色文件夾,右鍵后就不會出現(xiàn)Convert to Group這個選項。

第二步:使用文本編輯器打開 xxxxx.xcodeproj文件操作【或者直接 去到項目根目錄右擊 xxxxx.xcodeproj文件 - 顯示包內(nèi)容】:

image.png

1、打開 xxxxx.xcodeproj 文件后,找到 project.pbxproj 文件
刪除以下兩行:

minimizedProjectReferenceProxies = 1;
preferredProjectObjectVersion = 77;

2、修改 project.pbxproj文件中以下內(nèi)容:

objectVersion = 77;
改為:
objectVersion = 56;  // 如果 63 不行,可以試試 56 

保存修改,然后退出。
最后,你可以執(zhí)行 pod init 以及pod install 測試下是否可以了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容