Rei*_*ims 43 xcode ios flutter
我对 Flutter 完全陌生。
\n我收到了一个几个月前(2020 年 12 月)在 Visual Studio Code 上使用 Flutter 和 Dart 开发的项目,以便将其部署到 App \xc2\xa0Store上。
\n我想指出的是,当时该项目运行得非常好,甚至在 iPhone 上部署了测试版本。
\n我必须确保它可以在本地运行,然后我将其部署到 App\xc2\xa0Store。
\n所以我在我的 Visual Studio Code 中打开了该项目的源代码。我尝试编译它,但没有成功。我不知道当你打开一个项目的源代码时;有一些具体的配置要做。
\n我不确定在打开项目源代码时是否需要进行任何具体配置,但是在浏览论坛后,我意识到该错误一定来自我的 Flutter 的最新版本,并且不是应用程序开发时使用的版本。
\n因此,我按照Flutter iOS build failed an error of pod files: Podfile is out of date和Flutter error: Invalid `Podfile` file: noimplicit conversion of nil into String 中此解决方案的说明进行操作。我\xe2\x80\x99已经搜索了讨论,但我可以\xe2\x80\x99t似乎解决了问题以再次生成我的podfiles。只是现在这个错误是在编译时生成的:
\nLaunching lib/main.dart on iPhone 8 in debug mode...\nRunning pod install... 1,674ms\nCocoaPods\' output:\n\xe2\x86\xb3\n Preparing\n\n Analyzing dependencies\n\n Inspecting targets to integrate\n [!] Unable to find a target named `Runner` in project `Runner.xcodeproj`, did\n find `dev` and `prod`.\nRun Code Online (Sandbox Code Playgroud)\n我怎样才能解决这个问题?
\n我之前的 pod 文件是
\n# Uncomment this line to define a global platform for your project\n# platform :ios, \'9.0\'\n\n# CocoaPods analytics sends network stats synchronously affecting flutter build latency.\nENV[\'COCOAPODS_DISABLE_STATS\'] = \'true\'\n\nproject \'Runner\', {\n \'Debug\' => :debug,\n \'Profile\' => :release,\n \'Release\' => :release,\n}\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 generated_key_values = {}\n skip_line_start_symbols = ["#", "/"]\n File.foreach(file_abs_path) do |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 generated_key_values[podname] = podpath\n else\n puts "Invalid plugin specification: #{line}"\n end\n end\n generated_key_values\nend\n\ntarget \'Runner\' do\n # Flutter Pod\n\n copied_flutter_dir = File.join(__dir__, \'Flutter\')\n copied_framework_path = File.join(copied_flutter_dir, \'Flutter.framework\')\n copied_podspec_path = File.join(copied_flutter_dir, \'Flutter.podspec\')\n unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)\n # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.\n # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.\n # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.\n\n generated_xcode_build_settings_path = File.join(copied_flutter_dir, \'Generated.xcconfig\')\n unless File.exist?(generated_xcode_build_settings_path)\n raise "Generated.xcconfig must exist. If you\'re running pod install manually, make sure flutter pub get is executed first"\n end\n generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)\n cached_framework_dir = generated_xcode_build_settings[\'FLUTTER_FRAMEWORK_DIR\'];\n\n unless File.exist?(copied_framework_path)\n FileUtils.cp_r(File.join(cached_framework_dir, \'Flutter.framework\'), copied_flutter_dir)\n end\n unless File.exist?(copied_podspec_path)\n FileUtils.cp(File.join(cached_framework_dir, \'Flutter.podspec\'), copied_flutter_dir)\n end\n end\n\n # Keep pod path relative so it can be checked into Podfile.lock.\n pod \'Flutter\', :path => \'Flutter\'\n\n # Plugin Pods\n\n # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock\n # referring to absolute paths on developers machines .\n system(\'rm -rf .symlinks\')\n system(\'mkdir -p .symlinks/plugins\')\n plugin_pods = parse_KV_file(\'../.flutter-plugins\')\n plugin_pods.each do |name, path|\n symlink = File.join(\'.symlinks\', \'plugins\', name)\n File.symlink(path, symlink)\n pod name, :path => File.join(symlink, \'ios\')\n end\nend\n\ntarget \'prod\' do\n # Flutter Pod\n\n copied_flutter_dir = File.join(__dir__, \'Flutter\')\n copied_framework_path = File.join(copied_flutter_dir, \'Flutter.framework\')\n copied_podspec_path = File.join(copied_flutter_dir, \'Flutter.podspec\')\n unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)\n # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.\n # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.\n # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.\n\n generated_xcode_build_settings_path = File.join(copied_flutter_dir, \'Generated.xcconfig\')\n unless File.exist?(generated_xcode_build_settings_path)\n raise "Generated.xcconfig must exist. If you\'re running pod install manually, make sure flutter pub get is executed first"\n end\n generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)\n cached_framework_dir = generated_xcode_build_settings[\'FLUTTER_FRAMEWORK_DIR\'];\n\n unless File.exist?(copied_framework_path)\n FileUtils.cp_r(File.join(cached_framework_dir, \'Flutter.framework\'), copied_flutter_dir)\n end\n unless File.exist?(copied_podspec_path)\n FileUtils.cp(File.join(cached_framework_dir, \'Flutter.podspec\'), copied_flutter_dir)\n end\n end\n\n # Keep pod path relative so it can be checked into Podfile.lock.\n pod \'Flutter\', :path => \'Flutter\'\n\n # Plugin Pods\n\n # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock\n # referring to absolute paths on developers\' machines.\n system(\'rm -rf .symlinks\')\n system(\'mkdir -p .symlinks/plugins\')\n plugin_pods = parse_KV_file(\'../.flutter-plugins\')\n plugin_pods.each do |name, path|\n symlink = File.join(\'.symlinks\', \'plugins\', name)\n File.symlink(path, symlink)\n pod name, :path => File.join(symlink, \'ios\')\n end\nend\n\n# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.\ninstall! \'cocoapods\', :disable_input_output_paths => true\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 end\n end\nend\nRun Code Online (Sandbox Code Playgroud)\n新创建的看起来像:
\n# Uncomment this line to define a global platform for your project\n# platform :ios, \'9.0\'\n\n# CocoaPods analytics sends network stats synchronously affecting flutter build latency.\nENV[\'COCOAPODS_DISABLE_STATS\'] = \'true\'\n\nproject \'Runner\', {\n \'Debug\' => :debug,\n \'Profile\' => :release,\n \'Release\' => :release,\n}\n\ndef flutter_root\n generated_xcode_build_settings_path = File.expand_path(File.join(\'..\', \'Flutter\', \'Generated.xcconfig\'), __FILE__)\n unless File.exist?(generated_xcode_build_settings_path)\n raise "#{generated_xcode_build_settings_path} must exist. If you\'re running pod install manually, make sure flutter pub get is executed first"\n end\n\n File.foreach(generated_xcode_build_settings_path) do |line|\n matches = line.match(/FLUTTER_ROOT\\=(.*)/)\n return matches[1].strip if matches\n end\n raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"\nend\n\nrequire File.expand_path(File.join(\'packages\', \'flutter_tools\', \'bin\', \'podhelper\'), flutter_root)\n\nflutter_ios_podfile_setup\n\ntarget \'Runner\' do\n flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))\nend\n\npost_install do |installer|\n installer.pods_project.targets.each do |target|\n flutter_additional_ios_build_settings(target)\n end\nend\nRun Code Online (Sandbox Code Playgroud)\n实际上,当我跑步时flutter doctor,我得到:
Doctor summary (to see all details, run flutter doctor -v):\n[\xe2\x9c\x93] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 30.0.3)\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS\n[\xe2\x9c\x93] Chrome - develop for the web\n[\xe2\x9c\x93] Android Studio (version 4.1)\n[\xe2\x9c\x93] VS Code (version 1.55.2)\n[\xe2\x9c\x93] Connected device (2 available)\n\n\xe2\x80\xa2 No issues found!\nRun Code Online (Sandbox Code Playgroud)\n实际上在 Xcode 中打开我的项目会得到以下结果:
\n\n小智 110
这是一种错误。RunnerTests 应该手动添加。但不知何故该命令自动添加了它。可以参考iOS设备测试中的RunnerTests
但要解决这个问题,请打开Podfile并注释这些行:
# target 'RunnerTests' do
# inherit! :search_paths
# end
Run Code Online (Sandbox Code Playgroud)
ASA*_*EED 34
我遇到了这个问题。
无法找到
Runner Tests项目中指定的目标Runner.xcodeproj
我必须删除我的 ios 文件夹 ( Not recommended if you have done any changes to native IOS code),然后使用此命令重新创建它。
如果您对文件夹进行了任何更改IOS,请尝试此命令,而无需删除该ios目录。这应该会生成缺失的元素。
flutter create --platform ios .
Run Code Online (Sandbox Code Playgroud)
可能的原因
我在 .NET 以外的操作系统上创建的项目中注意到了这个问题mac。
我假设您以前使用过 Flutter 1.X。
这是我最近下载 Flutter v2.0.4 时所做的:
当我第一次打开旧项目时,Visual Studio Code 将显示我的所有文件都包含错误。所以我要做的就是跑步flutter pub get。这将消除错误。
接下来我尝试在 iOS 模拟器中以调试模式运行。之后,我ios使用 Xcode 打开(项目内部)文件夹,单击“targets”下的Runner并检查签名,然后再在 iPhone 上进行测试。
因此,就您的情况而言,请放弃您最近所做的任何更改,或者如果您首先需要它,则将其存储在 Git 中。并flutter pub get在模拟器上运行并测试它。这应该可以解决问题,他们会应用/弹出您的藏品,现在您就可以走了。
另请注意,每当您跑步时flutter clean,您都必须flutter pub get再次跑步。否则,您将看到 Visual Studio Code 将以红色显示库文件夹中的所有文件。
flutter clean如果flutter pub get不能正确完成工作,请运行此命令:
flutter clean
flutter pub get
cd ios
rm Podfile
pod setup
flutter build ios
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
58153 次 |
| 最近记录: |