Pod init和Pod install失败 - iOS Xcode beta 14.0。

6

我尝试执行pod init或者pod install时遇到了问题,报错如下。 使用Xcode 14 beta和操作系统版本12.4。自从升级Xcode和操作系统后就一直有这个问题。

pod install

Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
Ignoring executable-hooks-1.6.1 because its extensions are not built. Try: gem pristine executable-hooks --version 1.6.1
Ignoring gem-wrappers-1.4.0 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.4.0
Analyzing dependencies

[!] Smart quotes were detected and ignored in your Podfile. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
/usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface/error_report.rb:34:in `force_encoding': can't modify frozen String (FrozenError)
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface/error_report.rb:34:in `report'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:66:in `report_error'
    from /Users/azeemazeez/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:396:in `handle_exception'
    from /Users/azeemazeez/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:337:in `rescue in run'
    from /Users/azeemazeez/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:324:in `run'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `load'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `<main>'
/Users/azeemazeez/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:228:in `initialize_from_file': [Xcodeproj] Unknown object version (56). (RuntimeError)
    from /Users/azeemazeez/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:113:in `open'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1190:in `block (2 levels) in inspect_targets_to_integrate'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1189:in `each'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1189:in `block in inspect_targets_to_integrate'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1184:in `inspect_targets_to_integrate'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:106:in `analyze'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:416:in `analyze'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in `install!'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
    from /Users/azeemazeez/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `load'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `<main>'

我有几个解决方案,例如:

uninstall cocoa pods and reinstalled.

我也尝试了brew update

brew update
brew install fastlane
fastlane install_plugins

对我来说,它们都不起作用。仍然会收到以上错误。


1
请尝试使用 pod deintegrate 和 pod install 命令。 - stoikokolev
这很有帮助,但我已经将Xcode beta更改为Xcode! - AzeTech
只是提醒一下,对于开源项目,你可能会发现在 CocoaPods 的 GitHub 页面上创建一个问题会更容易获得成功。 - mfaani
8个回答

30

我将项目格式从Xcode 14.0改为Xcode 13.0,这对我起了作用。


1
这是唯一对我有效的东西。 - bmueller
我陷入了困境,没有任何解决方案……这是唯一一个对我有效的!谢谢。 - Fabrizio L.

7

首先在您的项目终端中运行以下命令:

sudo gem update xcodeproj 

然后运行。
pod init

2
将项目兼容性更改为13.0-对我有用 :)。点击这里查看截图。

由于您目前的回答不够清晰,请[编辑]以添加更多细节,帮助他人了解该如何解决问题。您可以在帮助中心找到有关编写好答案的更多信息。 - Community

1
这可能是问题所在:
Smart quotes were detected and ignored in your Podfile.

尝试在类似于vscode、vim或nano的文本编辑器中检查您的Podfile,并将所有引号替换为新引号。


1

我无法在Xcode beta中解决问题,尝试更改路径sudo xcode-select,重新安装cocoapods和gem,使用brew等方法,但都没有起作用。

然后将版本从Xcode beta 14.0更改为Xcode 13.4。

之后尝试了以下步骤:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

然后Pod被解除集成。
pod deintegrate

最终
pod install

然后开始工作...

(注:已保留HTML标签)

0
post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["DEVELOPMENT_TEAM"] = "Your Team ID"
      end
    end
  end
end

这个Podfile中的post_install脚本修复了它。似乎需要设置自己的开发团队。请用您项目的TeamID替换Your Team ID。 - Fu Carl
请记住,Stack Overflow 不仅旨在解决当前的问题,还要帮助未来的读者找到类似问题的解决方案,这需要理解底层代码。对于我们社区中的初学者和不熟悉语法的成员来说,这尤其重要。鉴于此,您能否编辑您的答案,包括您正在做什么的解释以及为什么您认为这是最好的方法? - Jeremy Caney

0

对于我来说,它在xcode 14 beta上运行良好。

sudo xcode-select -switch /Applications/Xcode-beta.app/Contents/Developer

0

XCODE 14.2搭配M1芯片和M2芯片百分之百工作

我曾经遇到类似的问题,经过3到4个小时的尝试,我找到了这个解决方案。默认情况下,系统会使用Ruby版本,我们需要绕过它,然后继续使用Cocoa Pods。

1.使用homebrew安装Ruby

brew install ruby

默认情况下,由gem安装的二进制文件将被放置在:/usr/local/lib/ruby/gems/2.7.0/bin中

您可能希望将此添加到您的PATH中。

Ruby是桶装的,这意味着它没有链接到/usr/local,因为macOS已经提供了这个软件,而安装另一个版本可能会引起各种麻烦。

如果您需要让Ruby首先运行,请运行以下命令(并将user_name替换为您的用户名):

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/user_name/.bash_profile 为了让编译器找到ruby,您可能需要设置:

export LDFLAGS="-L/usr/local/opt/ruby/lib"

export CPPFLAGS="-I/usr/local/opt/ruby/include"

按照以下步骤设置 PATH。将 user_name 替换为您的用户名

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/user_name/.bash_profile

echo 'export LDFLAGS="-L/usr/local/opt/ruby/lib"' >> ~/.bash_profile

echo 'export CPPFLAGS="-I/usr/local/opt/ruby/include"' >> ~/.bash_profile

source ~/.bash_profile

检查您的路径

ruby -v

然后在终端中会得到以下输出

ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin20]

user@MacBook-Air ios % which ruby

/usr/local/opt/ruby/bin/ruby

这就是全部设置好的 Ruby 版本,现在可以安装 CocoaPods 并开始使用了

sudo gem install -n /usr/local/bin cocoapods

稍后添加您的项目目标并运行 pod init

一切都正常工作


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接