出现场景
朋友的一个老项目,创建的时候用的是flutter 1.0版本。
现在让我帮忙改个东西,我的Flutter是2.0,导入项目后,在ios上编译时出现以下错误
Upgrading contents.xcworkspacedata Running pod install... CocoaPods' output: ↳ [!] Invalid `Podfile` file: no implicit conversion of nil into String. # from /Users/ado/my/work/flutter/testdemo4/ios/Podfile:58 # ------------------------------------------- # unless File.exist?(copied_framework_path) > FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) # end # ------------------------------------------- /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:318:in `rescue in block in from_ruby' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:312:in `block in from_ruby' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:50:in `instance_eval' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:50:in `initialize' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:310:in `new' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:310:in `from_ruby' /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:276:in `from_file' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/config.rb:205:in `podfile' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:160:in `verify_podfile_exists!' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:46:in `run' /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>' /usr/local/bin/pod:23:in `load' /usr/local/bin/pod:23:in `<main>' Error running pod install Error launching application on iPhone 12 Pro Max.
解决办法
根据错误提示,提示Podfile是无效文件,是Podfile中的内容造成的错误。
因为Podfile是在flutter 1.0的环境下运行生成的,估计是flutter1.0和2.0有一些配置上的不一样,所以我们先删除ios目录中的Podfile和Podfile.lock,然后再重新运行
flutter run
或者运行
flutter run ios
这样将会生成flutter 2.0的Podfile,编译ios就不会报错了。