添加 Firebase 后,Flutter 应用程序无法在 iOS 上启动

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

即使添加 Firebase,该应用程序也可以在 Android 上正常启动,但不能在 iOS 上启动。

我的 Pod 文件:

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

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',

        ## dart: PermissionGroup.calendar
        #  'PERMISSION_EVENTS=1',

        ## dart: PermissionGroup.reminders
        # 'PERMISSION_REMINDERS=1',

        ## dart: PermissionGroup.contacts
        # 'PERMISSION_CONTACTS=1',

        ## dart: PermissionGroup.camera
         'PERMISSION_CAMERA=1',

        ## dart: PermissionGroup.microphone
        # 'PERMISSION_MICROPHONE=1',

        ## dart: PermissionGroup.speech
        # 'PERMISSION_SPEECH_RECOGNIZER=1',

        ## dart: PermissionGroup.photos
         'PERMISSION_PHOTOS=1',

        ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
         'PERMISSION_LOCATION=1',

        ## dart: PermissionGroup.notification
         'PERMISSION_NOTIFICATIONS=1',

        ## dart: PermissionGroup.mediaLibrary
         'PERMISSION_MEDIA_LIBRARY=1',

        ## dart: PermissionGroup.sensors
        # 'PERMISSION_SENSORS=1'

      ]
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end

  end
end

我尝试了几种解决方案,但没有一个有效,我还将 Xcode 更新到 15.3,将 iOS 更新到 17.4,但这并不能解决问题。

错误:

Launching lib/main.dart on iPhone 15 Pro Max in debug mode...
Xcode build done.                                           454.1s
Failed to build iOS app
Error output from Xcode build:
↳
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
2
    { platform:iOS Simulator, id:08659800-D559-478A-8931-B251851D0BC5, OS:17.4, name:iPhone 15 Pro Max }
    ** BUILD FAILED **
2

Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/hp/cymv76nj76s6vwvm72j96gw00000gn/T/flutter_tools.JsDFZz/flutter_ios_build_temp_dir0AdLcc/temporary_xcresult_bundle

    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'FirebaseAuth-FirebaseAuth_Privacy' from project 'Pods')
    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'FirebaseMessaging-FirebaseMessaging_Privacy' from project 'Pods')
    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'FirebaseCrashlytics-FirebaseCrashlytics_Privacy' from project 'Pods')
 /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'gRPC-C++-grpcpp' from project 'Pods')
    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'gRPC-C++-gRPCCertificates-Cpp' from project 'Pods')
    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'gRPC-C++' from project 'Pods')
    warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'gRPC-C++' from project 'Pods')
    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'FirebaseFirestore' from project 'Pods')
 /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'FirebaseFirestoreInternal' from project 'Pods')
    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'FirebaseFirestoreInternal-FirebaseFirestoreInternal_Privacy' from project 'Pods')
    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'FirebaseFirestore-FirebaseFirestore_Privacy' from project 'Pods')
    note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
      note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
    warning: Run script build phase 'FlutterFire: "flutterfire upload-crashlytics-symbols"' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
    /Users/yassine/Documents/ExploreVo/Mobile app/user app/latest/exolorevo-user/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'Firebase' from project 'Pods')

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max.

我已经尝试了所有解决方案这里

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

但这又带来了另一个问题:

Launching lib/main.dart on iPhone 15 Pro Max in debug mode...
Xcode build done.                                           17.8s
Failed to build iOS app
Swift Compiler Error (Xcode): 'Flutter/Flutter.h' file not found
/Users/yassine/.pub-cache/hosted/pub.dev/nb_utils-7.0.2/ios/Classes/NbUtilsPlugin.h:0:8

Swift Compiler Error (Xcode): Could not build Objective-C module 'nb_utils'

Swift Compiler Error (Xcode): No such module 'Flutter'
/Users/yassine/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/darwin/Classes/messages.g.swift:9:9
messages.g.swift:9

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max.

知道如何解决这个问题吗?已经两天了!

ios flutter xcode firebase
1个回答
0
投票

我认为你必须将 firebase 选项添加到主 dart 中 它指定每个平台的单独凭据 如需信息,请访问此链接 Firebase 文档

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