ruby Cocoapods指向错误版本

2uluyalo  于 2023-04-20  发布在  Ruby
关注(0)|答案(7)|浏览(156)

我在项目的一个版本中遇到了一些问题。我发现这个answer,有人建议从机器中删除所有与cocoapods连接的东西并重新安装它。我确实遵循了以下步骤:

$ 'pod --version'
0.36.1

$ gem list --local | grep cocoapods
cocoapods (0.39.0.rc.1, 0.38.2, 0.38.1, 0.37.2)
cocoapods-core (0.39.0.rc.1, 0.38.2, 0.38.1, 0.37.2)
cocoapods-downloader (0.9.3, 0.9.1)
cocoapods-plugins (0.4.2)
cocoapods-search (0.1.0)
cocoapods-stats (0.6.2, 0.5.3)
cocoapods-trunk (0.6.4, 0.6.1)
cocoapods-try (0.5.1, 0.4.5)

$ gem uninstall cocoapods // and all others from the list above

问题是,当我再次grep所有cocoapods时,列表等于上面的一个,没有任何东西消失。

$ sudo gem uninstall cocoapods
Select gem to uninstall:
 1. cocoapods-0.37.2
 2. cocoapods-0.38.1
 3. cocoapods-0.38.2
 4. cocoapods-0.39.0.rc.1
 5. All versions
> 5

$ pod --version
// here was the error command not found, so everything fine

$ sudo gem install cocoapods
Fetching: cocoapods-0.38.2.gem (100%)
Successfully installed cocoapods-0.38.2
Parsing documentation for cocoapods-0.38.2
Installing ri documentation for cocoapods-0.38.2
Done installing documentation for cocoapods after 2 seconds
1 gem installed

$ pod --version
Could not find proper version of cocoapods (0.36.1) in any of the sources
Run `bundle install` to install missing gems.

但是为什么它要我安装0.36.1呢?不管怎样,正如它所要求的,我做到了:

$bundle install
Installing cocoapods-core 0.36.1
Installing cocoapods-downloader 0.8.1
Installing cocoapods-plugins 0.4.1
Installing cocoapods-trunk 0.6.0
Installing cocoapods-try 0.4.3
Installing cocoapods 0.36.1
// Many "using" dependencies

当我跑步时:

$ pod --version
0.36.1

我被卡住了:)为什么我不能有最新的发布版本?也许pod --version指向最新版本的cocoapods-core而不是只有cocoapods,所以一切都很好,我有正确的版本?

fcg9iug3

fcg9iug31#

  • 检查是否使用Gemfile,并且指定了cocoapods的版本。
  • 您可以通过pod *version* action使用特定版本。例如:pod _1.5.0.beta.1_ updatepod _1.5.0.beta.1_ install
amrnrhlw

amrnrhlw2#

对于任何试图更新cocoapods的人来说。在做了上述所有工作后,我无法解决这个问题。然后我前往解决的答案,不愿意删除RVM,我试图以另一种方式解决这个问题。
我发现我的问题确实存在于我的Gemfile中。
首先,运行gem install cocoapods以确保您下载了最新版本,或者您正在寻找的任何指定版本。
其次,确保您的项目Gemfile没有指定cocoapods版本号,而是简单地将其指定为:gem "cocoapods"如果你的gem没有,修改这个,然后运行bundle update来重新生成Gemfile.lock文件,你的问题应该就解决了。如果没有,继续删除Gemfile.lock文件,然后运行bundle update。你可以很容易地通过打开Gemfile.lock文件并搜索cocoapods-core <version number here>来检查哪个gem版本将被加载
此时,您可以进入项目并运行pod setup,然后使用pod --version检查cocoapods版本
现在你终于可以自由地运行pod install来替换Podfile.lock文件,回到你快乐的开发生活中去了。希望这能帮助到一些人,让他们免于浪费时间。

lawou6xi

lawou6xi3#

我的ruby版本似乎出现了一些问题。我仍然不知道是什么以及为什么。我已经通过这个解决方案解决了这个问题:https://stackoverflow.com/a/25021772/849616。之后一切正常。

r7knjye2

r7knjye24#

当迁移到更高的Swift版本时,您可能会遇到这个问题。假设您已经安装了cocoapods,您可能需要运行**bundle update**命令(可能需要sudo)。
有关更多详细信息,您可以查看:https://guides.cocoapods.org/using/a-gemfile.html
此外,我建议您执行以下操作:

  • 安装最新的Xcode版本。
  • 清除项目中的派生数据(而不仅仅是清除项目)。
  • 运行pod update命令。
0mkxixxg

0mkxixxg5#

我也有同样的问题。
在我的项目中,pod --versiongem which cocoapods总是返回不同的版本。
我所要做的就是删除我项目中的Gemfile.lock和bundle install。它删除了锁定的Cocoapods版本并安装一个新的。
希望这对这里的人有帮助。

yhived7q

yhived7q6#

我运行pod install,得到了这个错误:

Could not find proper version of cocoapods (1.11.3) in any of the sources

我跑了起来:

bundle install

之后pod install工作正常

qaxu7uf2

qaxu7uf27#

这是因为gem锁文件中的cocoapods版本与安装的版本不同。您可能安装了多个。
使用gem uninstall cocoapods删除cocoapod版本
然后使用bundle update将锁文件更新到正确的版本。
如果需要,请使用bundle install将其安装到正确的版本。

相关问题