在 VSCode 中设置 Firebase 后,在 iOS 模拟器上运行 Flutter 应用程序时出现“运行 pod install 时出错”

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

使用 Firebase 设置 Flutter 应用程序并将该应用程序连接到 Firebase 控制台后,我无法在 iOS 模拟器中运行该应用程序。

我的系统描述是 -

2017 Macbook Pro Intel i5 & MacOS 13.6.7

模拟器 -

iPhone 12 Pro Max iOS 17.2

调试控制台将主要错误显示为 -

Error running pod install
Error launching application on iPhone 12 Pro Max.

运行后我的 mac 上的 Ruby 版本

ruby -v

ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin22]

应用程序无需设置 Firebase 即可正常运行。我尝试了很多方法但仍然无法找到解决方案。

调试控制台中的警告消息是-

Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
      Using `ARCHS` setting to build architectures of target `Pods-RunnerTests`: (``)

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
    firebase_core: Using Firebase SDK version '10.27.0' defined in 'firebase_core'

    Resolving dependencies of `Podfile`

Error output from CocoaPods:
↳
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- ffi_c (LoadError)
        from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/ffi.rb:5:in `rescue in <top (required)>'
        from /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/ffi.rb:2:in `<top (required)>'
2
        from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'

...
...
...

from /usr/local/bin/pod:23:in `<main>'
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h' or 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle' (no such file), '/Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h' or 'x86_64')) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-arm64-darwin/lib/2.6/ffi_c.bundle (LoadError)


...
...
...

from /usr/local/bin/pod:23:in `<main>'

Error running pod install
Error launching application on iPhone 12 Pro Max.

Exited (1).

我相信 ruby 如何与我的系统中的 arm64 和 x86_64 架构一起工作存在一些问题,但我无法弄清楚如何解决该问题。

这些是我在参考了多个文档和资源后尝试的东西 -

  1. 更新并扑动 cocoapods -
flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec
flutter pub get
cd ios
pod install # (or on an M1+ mac: arch -x86_64 pod install)
cd ..
flutter build ios
flutter run
  1. 在 x86_64 架构的终端中安装
    ffi
    -
sudo arch -x86_64 gem install ffi
  1. 使用自制软件安装
    libffi
    -
brew install libffi
gem install ffi
  1. 在Flutter项目的Podfile中更改了iOS平台
platform :ios, '17.0'
  1. 安装 ruby 3.3.3 -
brew install [email protected] libyaml gmp readline

RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected]) --disable-install-doc" rbenv install 3.3.3
ios ruby flutter cocoapods ffi
1个回答
0
投票

我遇到了同样的问题,并设法使用此处发布的提示解决了它:https://github.com/CocoaPods/CocoaPods/issues/12440

帮助我的方法是使用以下命令卸载 CocoaPods:

sudo gem uninstall cocoapods

并使用以下命令重新安装:

brew install cocoapods

您可能需要先安装 Homebrew 包管理器。完成操作后,您可能需要重新打开代码编辑器,以便更新路径信息。

HTH

© www.soinside.com 2019 - 2024. All rights reserved.