flutter 错误无效的`Podfile` 文件:没有将 nil 隐式转换为 String。我搜索了讨论,但我似乎无法解决问题

aar*_*hi 27 xcode ios dart flutter

这是我收到的错误。我尝试了 flutter clean 并更改了一些行的语法,但我是 dart 和 flutter 的新手,所以我不太确定。我也重新安装了可可豆荚和红宝石,但我收到了同样的错误。我还确保将 ruby​​ 更新到最新版本。

  [!] Invalid `Podfile` file: no implicit conversion of nil into String.
         #  from /Users/(name)/Downloads/Projects/doctor_consultation_app/ios/Podfile:57
         #  -------------------------------------------
         #      unless File.exist?(copied_framework_path)
         >        FileUtils.cp(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
         #      end
         #  -------------------------------------------
Run Code Online (Sandbox Code Playgroud)

这是我的 pod 文件。

  [!] Invalid `Podfile` file: no implicit conversion of nil into String.
         #  from /Users/(name)/Downloads/Projects/doctor_consultation_app/ios/Podfile:57
         #  -------------------------------------------
         #      unless File.exist?(copied_framework_path)
         >        FileUtils.cp(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
         #      end
         #  -------------------------------------------
Run Code Online (Sandbox Code Playgroud)

Tat*_*rba 35

当我将 flutter sdk 更新到新的 flutter 2.0 时出现此错误,但我的项目是使用旧版本的 flutter sdk (1.22) 创建的。

通过固定它删除PodfilePodfile.lockIOS文件夹中,然后运行:

flutter run
Run Code Online (Sandbox Code Playgroud)

或者

flutter build ios
Run Code Online (Sandbox Code Playgroud)

这样flutter就会为flutter 2.0生成新的Podfile


小智 6

当我更新我的 mac --> BigSur 并使用 Ruby 时,我遇到了同样的问题。

我通过rm -rf ios和解决它flutter create .

然后在新的 ios 中修复一些文件更改

  • 不要在您现有的应用程序上使用它,这会删除我的 iOS 文件夹,并且 flutter create 命令将创建一个新项目。值得庆幸的是我使用 git 并且可以重置我的提交。 (3认同)