Flutter Cocoapods Mac M1 安装错误 - Flutter 设置

问题描述 投票:0回答:2

我无法在我的 Mac M1 计算机上运行具有 CocoaPods 的 flutter 应用程序。

颤动运行:

警告:CocoaPods 已安装但已损坏。跳过 Pod 安装。 您似乎已安装 CocoaPods,但它无法正常工作。 如果安装 CocoaPods 的 Ruby 版本与调用它时使用的版本不同,就会发生这种情况。 通常可以通过重新安装 CocoaPods 来解决此问题。 要重新安装,请参阅 https://guides.cocoapods.org/using/getting-started.html#installation 了解说明。 红宝石-v

ruby 2.6.3p62(2019-04-16 修订版 67580)[universal.arm64e-darwin20]

更新:我用 home-brew 更新了 ruby 版本,但它仍然给出相同的错误:

ruby -v ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]

更新2.0我尝试用自制软件安装CocoaPods

brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

flutter clean...
重新启动 Android Studio ...

同样的错误!

更新 3.0 新 Ruby 3.1.2p20 与 ffi 的组合

brew unlink cocoapods

brew uninstall cocoapods

尝试这个:https://medium.com/p-society/cocoapods-on-apple-silicon-m1-computers-86e05aa10d3e_

使用 Rosetta 打开终端

sudo arch -x86_64 gem install ffi

sudo gem install CocoaPods

--> 说 CocoaPods 未安装

所以我尝试这种方法:

https://stackoverflow.com/a/66842555/18936943

1- arch -x86_64 sudo gem install cocoapods -n /usr/local/bin

2- arch -x86_64 sudo gem install ffi

3- pod install

/usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:128:in `git_version': Failed to extract git version from `git --version` ("") (RuntimeError)
        from /usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:140:in `verify_minimum_git_version!'
        from /usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:49:in `run'
        from /usr/local/lib/ruby/gems/3.1.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
        from /usr/local/bin/pod:25:in `load'
        from /usr/local/bin/pod:25:in `<main>'

仍然没有解决方案...

最近的扑动医生:

timknogel@Tims-MacBook-Pro multiculturalapp % flutter doctor -v
[✓] Flutter (Channel stable, 2.10.5, on macOS 11.5.1 20G80 darwin-arm, locale en-ES)
    • Flutter version 2.10.5 at /Users/timknogel/FlutterDev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5464c5bac7 (13 days ago), 2022-04-18 09:55:37 -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/timknogel/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ✗ CocoaPods installed but not working.
        You appear to have CocoaPods installed but it is not working.
        This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
        This can usually be fixed by re-installing CocoaPods.
      To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.66.2)
    • VS Code at /Users/timknogel/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.38.1

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.127

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

which ruby

/usr/bin/ruby 我的机器:MacBook Pro(13英寸,M1,2020)Mac OS big sur

更新 4.0 我将 Mac 更新为 Mac OS Monterey 以安装 Roseta 2.0 https://github.com/flutter/flutter/wiki/Developing-with-Flutter-on-Apple-Silicon

sudo softwareupdate --install-rosetta --agree-to-license
然后我又试了一次:

sudo gem uninstall CocoaPods

brew install cocoapods 
brew link --overwrite cocoapods
还是同样的错误。
 brew unlink cocoapods

brew uninstall cocoapods`

sudo gem 安装 CocoaPods` 正在重新启动 IDE...

同样的错误。

然后我再次尝试使用标准 ruby 版本,但再次失败。

扑医生

[✓] Flutter (Channel stable, 2.10.5, on macOS 11.5.1 20G80 darwin-arm, locale en-ES)
• Flutter version 2.10.5 at /Users/timknogel/FlutterDev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (11 days ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/timknogel/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.66.2)
    • VS Code at /Users/timknogel/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.38.1

[✓] Connected device (2 available)
    • iPhone 13 (mobile) • 3253AB15-FB90-45F5-93CD-5A95FC029075 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2
      (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 100.0.4896.127
    ! Error: Failed to prepare device for development. This operation can fail if the version of the OS on the device is incompatible
      with the installed version of Xcode. You may also need to restart your mac and device in order to correctly detect compatibility.
      (code 806)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

Flutter 运行 -v 结果:

flutter run v.txt

更新6.0 Git相关?

参考这篇文章: https://github.com/CocoaPods/CocoaPods/issues/8661

我用自制程序安装了 git,以防 CocoaPods 由于 git 版本而无法工作。

之前:

git --version
git version 2.32.0 (Apple Git-132)

1.) 通过 home-brew 安装 git

之后:

brew install git

git --version

git version 2.36.0

2.) 将路径变量更改为:

zshrc 文件:

导出 PATH=$PATH:/Users/timknogel/FlutterDev/flutter/bin

导出 JAVA_HOME=$(/usr/libexec/java_home)

导出 PATHTWO="/usr/local/opt/ruby/bin:$PATH"

导出 PATHTHREE=/usr/local/bin

最后一个应该指向 git 版本,但我不确定我是否以正确的方式完成了...我不知道这个路径变量...

当我写作时

git --version I get back:
git version 2.36.0

这样终端就可以查阅gitversion了。为什么不能扑动呢?我对 PATH 不太了解。但我不确定它是否真的相关,因为我没有帖子中提到的 GIT 名称问题。

3.) 我尝试将 Cocapods 降级到 1.10.2,但仍然不起作用。

有人可以帮我吗?

ruby flutter cocoapods homebrew
2个回答
0
投票

这对我有用:

  1. 安装最新版本的 Ruby
  2. 重新安装CocoaPods

0
投票

这终于在 M1 mac 上对我有用了

  1. 将 ruby 更新到最新版本并确保其已链接
    brew upgrade ruby && brew link ruby --force
  2. 打开新终端以确保您拥有所有内容的最新版本
  3. brew reinstall cocoapods
  4. rm podfile.lock
  5. sudo gem update --system 3.4.21
  6. sudo gem install ffi
  7. pod install
    在ios目录下
  8. flutter run
© www.soinside.com 2019 - 2024. All rights reserved.