Flutter Podfile 和 Pods 文件夹未在 ios 目录中创建

aar*_*nfg 17 ios flutter

使用向导从 Android Studio 创建了一个新的 Flutter 项目。

新创建的项目文件夹在 ios 目录中没有任何 Pods 文件夹或 podfile。

这个 Flutter.io页面指​​出(强调我的):

虽然 Flutter 项目的 iOS 文件夹中有一个 Podfile,但只有在添加每个平台集成所需的本机依赖项时才使用它。

我的 ios 目录中根本没有 podfile。

我在一个不同的问题中发现了这条评论,建议在 ios 模拟器上运行项目会生成文件,但在 sim 和设备上运行项目都不会为我创建任何 podfile。

我错过了新的 flutter 项目创建的 ios 方面的某些步骤吗?如果没有 podfile,我就无法添加特定于 ios 的依赖项。

的输出flutter doctor

[?] Flutter (Channel beta, v0.5.1, on Mac OS X 10.12.6 16G1408, locale en-US)
[?] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[?] iOS toolchain - develop for iOS devices (Xcode 9.2)
[?] Android Studio (version 3.1)
[!] VS Code (version 1.25.1)
[?] Connected devices (1 available)
Run Code Online (Sandbox Code Playgroud)

Liv*_*ock 24

这是我通常做的:

  1. 进入ios文件夹
  2. 删除Podfile.lock文件
  3. rm -rf Pods
  4. pod cache clean --all
  5. pod deintegrate
  6. pod setup
  7. pod install

你可能还想做

pod repo update

  • 好吧,也没有 `Podfile.lock` 文件......! (13认同)
  • 于 02/2022 工作,谢谢! (5认同)
  • 遵循此处的所有步骤,但似乎最后一个对于本地环境来说是最关键的。`pod 仓库更新` (2认同)

小智 20

一旦你运行flutter build iosPodfilePodfile.lock就会在ios目录中为你创建一个。

按照部署步骤官方文档中的步骤操作

  • 好的,我明白了,我必须包含一个具有本机对应项的 Flutter 插件(例如:webview_flutter:^0.3.21)。现在它生成了 Podfile (3认同)
  • 实际上只需在project.yaml 的依赖项列表中添加“webview_flutter: ^1.0.7”,然后运行构建命令即可。请注意,我选择了“webview_flutter”作为示例,但任何具有本机对应项的 dep 都可以完成这项工作。 (2认同)

Yas*_*kar 6

我建议简单地转到您的 Flutter Package 并执行它,flutter create . 它会自动创建所有丢失的文件,甚至 Podfile。我在我的项目中使用了这个命令,并且卓有成效。

  • 去你的flutter包意味着什么?项目文件夹? (4认同)
  • 这绝对是人们应该尝试的事情。这就像魔法一样! (2认同)

Liv*_*ock 5

最近,我遇到了同样的问题。即使我在 pubspec.yaml 文件中添加依赖包,也没有创建 Podfile。最后,我必须在 ios 目录中手动添加一个 Pod 文件,并发出“pod deintegrate”、“pod setup”和“pod install”。

\n\n

这是我的 podfile。你可以尝试一下:

\n\n
# Uncomment this line to define a global platform for your project\nplatform :ios, \'9.0\'\n\n# CocoaPods analytics sends network stats synchronously affecting flutter build latency.\nENV[\'COCOAPODS_DISABLE_STATS\'] = \'true\'\n\npod \'Firebase/Core\'\npod \'FBSDKLoginKit\' #optional\npod \'GoogleAnalytics\'\n\ndef parse_KV_file(file, separator=\'=\')\n  file_abs_path = File.expand_path(file)\n  if !File.exists? file_abs_path\n    return [];\n  end\n  pods_ary = []\n  skip_line_start_symbols = ["#", "/"]\n  File.foreach(file_abs_path) { |line|\n      next if skip_line_start_symbols.any? { |symbol| line =~ /^\\s*#{symbol}/ }\n      plugin = line.split(pattern=separator)\n      if plugin.length == 2\n        podname = plugin[0].strip()\n        path = plugin[1].strip()\n        podpath = File.expand_path("#{path}", file_abs_path)\n        pods_ary.push({:name => podname, :path => podpath});\n      else\n        puts "Invalid plugin specification: #{line}"\n      end\n  }\n  return pods_ary\nend\n\ntarget \'Runner\' do\n  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock\n  # referring to absolute paths on developers\' machines.\n  use_frameworks! \n  system(\'rm -rf .symlinks\')\n  system(\'mkdir -p .symlinks/plugins\')\n\n  # Flutter Pods\n  generated_xcode_build_settings = parse_KV_file(\'./Flutter/Generated.xcconfig\')\n  if generated_xcode_build_settings.empty?\n    puts "Generated.xcconfig must exist. If you\'re running pod install manually, make sure flutter packages get is executed first."\n  end\n  generated_xcode_build_settings.map { |p|\n    if p[:name] == \'FLUTTER_FRAMEWORK_DIR\'\n      symlink = File.join(\'.symlinks\', \'flutter\')\n      File.symlink(File.dirname(p[:path]), symlink)\n      pod \'Flutter\', :path => File.join(symlink, File.basename(p[:path]))\n    end\n  }\n\n  # Plugin Pods\n  plugin_pods = parse_KV_file(\'../.flutter-plugins\')\n  plugin_pods.map { |p|\n    symlink = File.join(\'.symlinks\', \'plugins\', p[:name])\n    File.symlink(p[:path], symlink)\n    pod p[:name], :path => File.join(symlink, \'ios\')\n  }\nend\n\n\n#pre_install do |installer|\n  # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289\n # Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}\n#end\n\npost_install do |installer|\n  installer.pods_project.targets.each do |target|\n    target.build_configurations.each do |config|\n      config.build_settings[\'ENABLE_BITCODE\'] = \'NO\'\n      config.build_settings[\'SWIFT_VERSION\'] = \'4.2\'\n    end\n\n    # Peter aded on 8 Oct 2018\n    # workaround for https://github.com/CocoaPods/CocoaPods/issues/7463\n    #target.headers_build_phase.files.each do |file|\n     # file.settings = { \'ATTRIBUTES\' => [\'Public\'] }\n    #end\n\n  end\nend\n
Run Code Online (Sandbox Code Playgroud)\n\n

另外,我尝试使用 Vcode 创建一个新的 Flutter 项目。在 pubspec.yaml 文件中添加包,保存并自动创建 podfile,

\n\n

使用Vcode创建一个新的Flutter项目

\n\n
    \n
  1. 启动 VS 代码
  2. \n
  3. 调用视图>命令面板\xe2\x80\xa6
  4. \n
  5. 输入 \xe2\x80\x98flutter\xe2\x80\x99,然后选择 \xe2\x80\x98Flutter: New Project\xe2\x80\x99 操作
  6. \n
  7. 输入项目名称(例如myapp),然后按Enter键
  8. \n
  9. 指定放置项目的位置,然后按蓝色的“确定”\n按钮
  10. \n
  11. 等待项目创建继续,main.dart 文件出现\n
  12. \n
  13. 在 pubspec.yaml 文件中添加包并保存。
  14. \n
  15. 应该创建 podfile。
  16. \n
\n