无法在项目“Runner.xcodeproj”中找到名为“Runner”的目标确实找到了“dev”和“prod”

Posted

技术标签:

【中文标题】无法在项目“Runner.xcodeproj”中找到名为“Runner”的目标确实找到了“dev”和“prod”【英文标题】:Unable to find a target named `Runner` in project `Runner.xcodeproj` did find `dev` and `prod` 【发布时间】:2021-07-28 01:16:17 【问题描述】:

所以,我对 Flutter 完全陌生。

我收到了一个几个月前(2020 年 12 月)开发的项目,该项目使用颤振和飞镖的 Visual Studio 代码开发,以便将其部署到应用商店。

我想指出,当时该项目运行得非常好,甚至已经在 iphone 上部署了测试版本。

我必须确保它在本地运行,然后我将它部署到应用商店。

所以我在我的visual studio中打开了项目的源代码,我尝试编译了但是没有成功,不知道大家打开项目源代码的时候有没有具体的配置做,

我不确定在打开项目的源代码时是否需要进行任何特定的配置,但是在浏览了论坛之后,我意识到错误一定来自我的最新版本的flutter,那就是不是开发应用程序的版本。

所以我遵循了来自此解决方案的说明Flutter ios build failed an error of pod files: Podfile is out of date 和这里 <.https: nil-into-string> 再次生成我的 podfile。除了现在这个错误是在编译时产生的

Launching lib/main.dart on iPhone 8 in debug mode...
Running pod install...                                           1,674ms
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
    [!] Unable to find a target named `Runner` in project `Runner.xcodeproj`, did
    find `dev` and `prod`.

请问有人有意见吗?

我之前的 pod 文件是


# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', 
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,


def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  generated_key_values = 
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) do |line|
    next if skip_line_start_symbols.any?  |symbol| line =~ /^\s*#symbol/ 
    plugin = line.split(pattern=separator)
    if plugin.length == 2
      podname = plugin[0].strip()
      path = plugin[1].strip()
      podpath = File.expand_path("#path", file_abs_path)
      generated_key_values[podname] = podpath
    else
      puts "Invalid plugin specification: #line"
    end
  end
  generated_key_values
end

target 'Runner' do
  # Flutter Pod

  copied_flutter_dir = File.join(__dir__, 'Flutter')
  copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
    # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
    # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
    # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

    generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
    unless File.exist?(generated_xcode_build_settings_path)
      raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
    end
    generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
    cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

    unless File.exist?(copied_framework_path)
      FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
    end
    unless File.exist?(copied_podspec_path)
      FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
    end
  end

  # Keep pod path relative so it can be checked into Podfile.lock.
  pod 'Flutter', :path => 'Flutter'

  # Plugin Pods

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers machines .
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.each do |name, path|
    symlink = File.join('.symlinks', 'plugins', name)
    File.symlink(path, symlink)
    pod name, :path => File.join(symlink, 'ios')
  end
end

target 'prod' do
  # Flutter Pod

  copied_flutter_dir = File.join(__dir__, 'Flutter')
  copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
    # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
    # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
    # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

    generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
    unless File.exist?(generated_xcode_build_settings_path)
      raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
    end
    generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
    cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

    unless File.exist?(copied_framework_path)
      FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
    end
    unless File.exist?(copied_podspec_path)
      FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
    end
  end

  # Keep pod path relative so it can be checked into Podfile.lock.
  pod 'Flutter', :path => 'Flutter'

  # Plugin Pods

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.each do |name, path|
    symlink = File.join('.symlinks', 'plugins', name)
    File.symlink(path, symlink)
    pod name, :path => File.join(symlink, 'ios')
  end
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

新创建的看起来像

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
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
  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

实际上,当我运行颤振医生时,我得到了


Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)
[✓] android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.55.2)
[✓] Connected device (2 available)

• No issues found!

实际上在 xcode 中打开我的项目给了我这个

【问题讨论】:

你是先用xCode打开的吗? 也许***.com/questions/54467284/…可以帮到你。 能否请您指定以前的flutter版本,当前版本然后运行flutter doctor并在这里分享输出? @HuthaifaMuayyad 我想在尝试在应用商店发布应用时使用它...我真的不知道它是如何工作的 @AlexanderDischberg 我修改了我的帖子,以便有足够的空间来粘贴我的 pod 文件 【参考方案1】:

我假设您以前使用过 Flutter 1.X。所以当我最近下载 Flutter v2.0.4 并且第一次打开我的旧项目时,vscode 会显示我所有的文件都包含错误。所以我要做的是运行flutter pub get。这将摆脱错误。接下来我尝试在 iOS 模拟器中以调试模式运行。之后,我用 xcode 打开 ios(在项目内)文件夹,单击“targets”下的 Runner 并检查签名,然后在我的 iphone 上进行测试。

因此,在您的情况下,请丢弃您最近所做的任何更改,或者如果您首先需要它,请使用 git 将其存储。并运行flutter pub get 并先在模拟器上进行测试。

还请注意,无论何时运行flutter clean,都必须再次运行flutter pub get。否则你会看到 VSCode 会将你在 lib 文件夹中的所有文件显示为红色。

$ flutter clean
$ flutter pub get
$ cd ios
$ rm Podfile
$ pod setup
$ flutter build ios

【讨论】:

我试了一下,但我得到了这个错误,假设我的 podfile 仍然有问题 ` Running pod install... 1,940ms CocoaPods' 输出:↳ [!] Invalid Podfile file :没有将 nil 隐式转换为字符串。 # 来自 /Users/vanessa/Documents/VSProjects/Teichmann-master-org/ios/Podfile:54 # --------------------------- ---------------- # unless File.exist?(copied_framework_path) > FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), mapped_flutter_dir) # end `跨度> @Reims 好的,我添加了一些额外的步骤,我在更新我的颤振版本时记录了这些步骤。

以上是关于无法在项目“Runner.xcodeproj”中找到名为“Runner”的目标确实找到了“dev”和“prod”的主要内容,如果未能解决你的问题,请参考以下文章

架构 x86_64 的未定义符号,颤振 ios

无法从“firebase.js”解析模块“firebase”:在项目中找不到 Firebase

Xamarin 无法构建到设备 - 工具退出,代码:1。输出:错误:在钥匙串中找不到指定的项目

在 Xcode 项目中找不到 Firebase 文件

在 CMake 项目中找不到 spdlog.h

在 PhoneGap 项目中找不到 plist