【问题标题】:Flutter 2.8.0 will not deploy and run project on iOS simulator (was working on 2.5.3)Flutter 2.8.0 不会在 iOS 模拟器上部署和运行项目(在 2.5.3 上工作)
【发布时间】:2022-01-15 13:25:39
【问题描述】:

我的开发环境如下:

  • Mac Mini M1
  • Mac OS 蒙特雷
  • Visual Studio 代码
  • 颤振 2.8.0
  • iPhone 12 Pro Max(iOS 模拟器)

Flutter 依赖项: 依赖项: 扑: sdk:颤动 库比蒂诺图标:^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)

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

谢谢。

【问题讨论】:

  • 错误是fatal error: module 'firebase_auth' not found @import firebase_auth; 删除 pod 并手动安装。也许它会,我今天迁移了颤振,我对 firebase auth 没有任何问题
  • @Chance 您好 Chance,您在使用 Apple 芯片(M1 或更高版本)的 Mac 上吗?如果是这样,您能否提供删除 pod 并手动安装的确切步骤?

标签: ios firebase flutter authentication


【解决方案1】:

尝试以下步骤:

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

Podfile

# 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

【讨论】:

  • 这并没有解决我的问题。 (我的错误类型与作者完全相同)。降级是目前唯一的选择..
  • @HugHunter 你是如何执行降级的?当我运行“flutter version”时,找不到命令?我的路上肯定有颤振/垃圾箱。谢谢
  • @dmalikyar 使用 "flutter downgrade v2.5.3" 进行降级,它可能会说成功但仍然在 IDE 中显示 2.8。在这种情况下,再次运行该命令以下载旧版本
【解决方案2】:

我设法通过在 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-07
    • 2021-08-31
    • 2020-10-24
    • 2022-09-28
    • 1970-01-01
    • 2022-01-17
    相关资源
    最近更新 更多