尝试使用 Xcode 存档 iOS 应用程序时出现“Flutter/Flutter.h 文件未找到”

问题描述 投票:0回答:1

当我尝试存档 iOS 应用程序以上传到 AppStore 连接时,遇到一些错误。我从 Xcode 的“产品”选项卡中选择了“存档”选项。 Pod 安装完成,没有任何错误,但构建失败。确切的错误如下图所示。 enter image description here

我还尝试了来自终端的

flutter build ios --release
命令。但这也以错误结束。错误很长。但从如下图所示的行开始。 enter image description here

我尝试了多种方法,如

flutter clean
pod disintegrate
pod install
,但没有任何效果。

为了更好地理解,我在此处附加了 podfile:

# Uncomment this line to define a global platform for your project
# platform :ios, '12.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
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
    config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
   end
  end
 end
ios flutter xcode
1个回答
1
投票

我猜你的

Podfile
缺少对
flutter_additional_ios_build_settings
的一个重要调用。您可以采取以下措施:

  1. 确保

    Flutter
    本身是最新的(在撰写本文时为
    3.24.3
    )。如果没有 – 我强烈建议更新。

  2. 在您的

    Podfile
    中,将
    flutter_additional_ios_build_settings(target)
    添加到
    post_install
    块,这样它就会开始看起来像这样:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    // Line below is what you should add.
    flutter_additional_ios_build_settings(target)
    // This is your content, I left it untouched, but I'm not sure
    // if it still required though.
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
     end
  end
end
  1. 清理您的项目。清洁越深越好,但就我而言,只需

    flutter clean
    就足够了。但是,也许也值得删除
    ios/Pods
    ios/.symlinks
    ios/Podfile.lock

  2. 构建!

这些步骤足以解决我的问题,希望对您有所帮助。祝你好运!

© www.soinside.com 2019 - 2024. All rights reserved.