Flutter 2.8.0 不会在 iOS 模拟器上部署和 运行 项目(在 2.5.3 上工作)

Flutter 2.8.0 will not deploy and run project on iOS simulator (was working on 2.5.3)

我的开发环境如下:

Flutter 依赖项: 依赖项: 扑: SDK: 颤动 cupertino_icons: ^1.0.2 firebase_core: ^1.10.5 firebase_auth: ^3.3.3 google_sign_in: ^5.2.1 flutter_login_facebook: ^1.2.0
提供商:^6.0.1

当我尝试构建和 运行 应用程序时,出现以下错误:

正在 iPhone 12 Pro Max 上以调试模式启动 lib/main.dart... Xcode 构建完成。 18.5s 无法构建 iOS 应用 Xcode 构建的错误输出: ↳ ** 构建失败 ** Xcode 的输出: ↳ /Users/daoudmalikyar/Documents/dev/Udemy/flutter_firebase/time_tracker/ios/Runner/GeneratedPluginRegistrant.m:12:9: 致命错误:找不到模块 'firebase_auth' @import firebase_auth; ~~~~~~~^~~~~~~~~~~~~ 产生 1 个错误。 注意:使用新的构建系统 注:规划 注意:构建准备完成 注意:并行构建目标 /Users/daoudmalikyar/Documents/dev/Udemy/flutter_firebase/time_tracker/ios/Pods/Pods.xcodeproj: 警告:iOS 模拟器部署目标 'IPHONEOS_DEPLOYMENT_TARGET' 设置为 8.0,但支持的部署目标版本范围为 9.0 到 15.0.99。 (在项目 'Pods' 的目标 'AppAuth' 中) /Users/daoudmalikyar/Documents/dev/Udemy/flutter_firebase/time_tracker/ios/Pods/Pods.xcodeproj: 警告:iOS 模拟器部署目标 'IPHONEOS_DEPLOYMENT_TARGET' 设置为 8.0,但支持的部署目标版本范围为 9.0 到 15.0.99。 (在项目 'Pods' 的目标 'GoogleSignIn' 中) 无法为模拟器构建应用程序。 在 iPhone 12 Pro Max 上启动应用程序时出错。 退出 (sigterm)

我已经尝试了几个在网上找到的潜在修复方法,但 none 似乎可以解决问题。同样,这段代码 运行ning 在 2.5.3 下没问题。 当我尝试在 XCode 中构建项目时,我得到与 'firebase_auth' 未找到相同的错误。任何建议表示赞赏。

谢谢。

请尝试以下步骤:

  1. flutter clean
  2. cd ios
  3. rm -rf Podfile.lock
  4. 用下面的 Podfile 替换你的 Podfile 并在第二行设置目标 iOS 平台
  5. pod install
  6. cd ..
  7. flutter run

播客文件

# Uncomment this line to define a global platform for your project
platform :ios, '10.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__))
end

post_install do |installer|

  puts 'Determining pod project minimal deployment target'

  pods_project = installer.pods_project
  deployment_target_key = 'IPHONEOS_DEPLOYMENT_TARGET'
  deployment_targets = pods_project.build_configurations.map{ |config| config.build_settings[deployment_target_key] }
  minimal_deployment_target = deployment_targets.min_by{ |version| Gem::Version.new(version) }

  puts 'Minimal deployment target is ' + minimal_deployment_target
  puts 'Setting each pod deployment target to ' + minimal_deployment_target

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings[deployment_target_key] = minimal_deployment_target
    end
  end
end

我通过在 ios/Podfile:

中添加三行来让它工作
 post_install do |installer|
   installer.pods_project.targets.each do |target|
     flutter_additional_ios_build_settings(target)
+    target.build_configurations.each do |config|
+      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386"
+   end
   end
 end

查看此评论以获取更多信息: https://github.com/flutter/flutter/issues/94914#issuecomment-992898782