这是一个非常糟糕和不幸的错误。尝试解决了几个小时后,我终于找到了解决方案。问题是,您的Podfile没有与pubspec.yaml文件更新。我认为,您的Podfile几乎是空的:
target 'Runner' do
use_frameworks!
end
但这是一个大问题。如果您尝试执行以下操作:$ rm Podfile,然后 $ pod init,将创建此Podfile。
以下是我的解决方案:
... 但在此之前,您必须检查一些内容,否则我的解决方案可能无法正常工作:运行:
$ pod install
如果此命令的结果为:
There are 0 dependencies from the Podfile and 0 total pods installed.
你可以放心,这个解决方案有效。否则它也会起作用,但也许你应该在评论中写下命令行的结果!
现在回到解决方案...
步骤:使用以下代码更新您的Podfile(请删除文件中的旧内容):
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
现在Podfile正在更新您在 podspec.yaml 文件中写下来的 pods。
现在,您需要通过调用以下命令将podspec.yaml文件与Xcode的pods同步:
$ pod install
然后您将看到所有的Pod都在下载。之后,您可以通过调用flutter run或在编辑器中运行您的Flutter项目。
注意:Podfile.lock文件列出了每个Pod的版本和Pods。'真正的' Podfile仅用于podspec.yaml文件与真正的Pod之间的连接。如果您查看Podfile.lock文件,您会发现没有任何Pod被写下来,这就是问题所在。如果没有任何Pod可安装,每个模块(例如'cloud-firestore')都将找不到...
我希望这个答案对您有所帮助,如果有什么地方不起作用,您可以在评论中问我,但我知道这不会发生:)
macOS编辑:
platform :osx, '10.11'
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path =
File.expand_path(File.join('..', 'Flutter', 'ephemeral',
'Flutter-
Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If
you're running pod install manually, make sure \"flutter pub
get\"
is
executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #.
{generated_xcode_build_settings_path}. Try deleting Flutter-
Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools',
'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_macos_pods
File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end
ios/
文件夹中添加你的Podfile
的片段?此外,你能否尝试使用Xcode
构建此应用程序,这可能会给你一些更好的日志。 - yusufpats