当我尝试在 iOS 上构建 Flutter 应用程序时,出现此错误:
### Error
```
NoMethodError - undefined method `present?' for nil:NilClass
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:100:in `validate_conflicting_external_sources!'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:85:in `block in validate_pod_directives'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:84:in `each'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:84:in `validate_pod_directives'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/podfile_validator.rb:40:in `validate'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/analyzer.rb:225:in `validate_podfile!'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer/analyzer.rb:104:in `analyze'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer.rb:422:in `analyze'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/user_interface.rb:64:in `section'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/installer.rb:162:in `install!'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/command/install.rb:52:in `run'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/lib/cocoapods/command.rb:52:in `run'
/Users/User/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.13.0/bin/pod:55:in `<top (required)>'
/Users/User/.rvm/rubies/ruby-2.7.0/bin/pod:25:in `load'
/Users/User/.rvm/rubies/ruby-2.7.0/bin/pod:25:in `<main>'
/Users/User/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:22:in `eval'
/Users/User/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:22:in `<main>'
```
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=undefined+method+%60present%3F%27+for+nil%3ANilClass&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...
- pod install fails while trying to call present? on a nil when using activesupport 7.1.0
https://github.com/CocoaPods/CocoaPods/issues/12089 [closed] [9 comments]
a week ago
- Unable to see XCode/SwiftUI Previews within CocoaPods frameworks
https://github.com/CocoaPods/CocoaPods/issues/9275 [open] [58 comments]
10 Sep 2023
- "Error 'DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead' in Xcode 15 beta 5"
https://github.com/CocoaPods/CocoaPods/issues/12012 [closed] [94 comments]
a week ago
and 12 more at:
https://github.com/cocoapods/cocoapods/search?q=undefined%20method%20%60present%3F%27%20for%20nil&type=Issues&utf8=✓
Error running pod install
Error launching application on iPhone 15 Pro Max.
默认的 Flutter Counter 应用程序运行良好。 我有一台配备 M2 Pro 芯片的 Macbook。
我尝试过: 1. 扑干净 扑扑酒吧得到 2. sudo arch -x86_64 gem install ffi 3. 光盘 arch -x86_64 pod 安装 4. 光盘 pod install --repo-update
您看到的错误消息与 CocoaPods(iOS 项目的依赖项管理器)的问题有关。好像是使用了一个叫present的方法造成的?在您的依赖项之一中的 nil 对象上。这是一个与 Ruby 相关的错误,因为 CocoaPods 是一个 Ruby gem。
尝试:
检查您的依赖版本: 首先,确保您使用的是 Flutter 和 CocoaPods 依赖项的正确版本。您可以检查 pubspec.yaml 文件中的 Flutter 依赖项以及 Podfile 中的 CocoaPods 依赖项。
更新 CocoaPods: 确保您安装了最新版本的 CocoaPods。您可以通过运行以下命令来更新 CocoaPods:
gem update cocoapods
检查Ruby版本: 确保您使用正确的 Ruby 版本。该错误表明您正在使用 Ruby 2.7.0。确保您的项目在 .ruby-version 文件或 Gemfile 中指定了正确的 Ruby 版本。
删除并重新安装 Pod: 删除 ios 目录中的 Pods 目录和 Podfile.lock 文件:
cd ios
rm -rf Pods Podfile.lock
然后,运行 pod install 重新安装依赖项:
pod install
flutter upgrade
检查 CocoaPods 插件问题: 如果您的项目中有任何 CocoaPods 插件或自定义配置,请检查它们是否导致问题。暂时删除它们并尝试在没有它们的情况下构建项目。
检查项目特定问题: 调查您的项目代码是否存在任何可能导致此问题的问题,例如库或插件的错误使用。
重新启动: 有时,只需重新启动计算机就可以解决与依赖项和构建相关的奇怪问题。