所以我在为 flutter 发布模式构建 Flutter 应用程序时遇到了问题。
当我在调试模式下构建 Flutter 应用程序时,它工作正常,我可以在任何模拟器中使用我的应用程序,没有任何问题。但是,当我单击编辑方案并尝试在发布模式下运行它时,构建失败,并且找不到 cloud_firestore 模块。
我尝试构建发布模式的原因是,当我向应用商店提交应用程序时,它几乎立即被拒绝,原因是应用程序在启动时崩溃了。
应用程序在调试模式下运行良好
XCode版本:v14.2
Flutter doctor:没有错误
Cocoapods 版本:1.15.2
Flutter版本:3.19.5(稳定版)
Dart 版本:3.3.3
Pod文件内容:
platform :ios, '12.0'
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|
flutter_additional_ios_build_settings(target)
end
end
Pubspec.yaml 内容:
name: lifenavigator
version: 1.0.0+1
publish_to: none
description: A new Flutter project.
environment:
sdk: '>=3.2.3 <4.0.0'
dependencies:
cupertino_icons: ^1.0.2
get: 4.6.6
flutter:
sdk: flutter
google_fonts: 6.1.0
firebase_core: ^2.27.0
firebase_auth: ^4.17.8
font_awesome_flutter: ^10.7.0
convex_bottom_bar: ^3.2.0
cloud_firestore: ^4.15.8
firebase_messaging: ^14.7.19
google_sign_in: ^6.2.1
flutter_facebook_auth: ^6.1.1
flutter_dotenv: ^5.1.0
dio: ^5.4.1
url_launcher: ^6.2.5
flutter_launcher_icons: ^0.13.1
google_mobile_ads: ^5.0.0
dev_dependencies:
flutter_lints: ^3.0.2
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.13.1"
flutter_launcher_icons:
android: "launcher_icon"
ios: true
image_path: "assets/applogo.png"
flutter:
uses-material-design: true
assets:
- assets/
- .env
我尝试过的解决方案: 我尝试清理以前的构建并再次构建。
我尝试了
Flutter upgrade
和pod repo update
和flutter pub get
和pod install
我尝试在 Podfile 中添加 cloudFirestore 作为
pod 'FirebaseCore', :modular_headers => true
(触发了一个新错误)
我试图构建发布模式的应用程序,但构建失败,并且找不到模块“cloud_firestore”