首页 > 解决方案 > 添加 firebase_messaging 后无法为 iOS 构建

问题描述

来自 Xcode 的错误错误

颤振医生-v

[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.7 19H524 darwin-x64, locale en-SA)

• Flutter version 1.22.5 at /Users/raitotec/developer/flutter
• Framework revision 7891006299 (5 months ago), 2020-12-10 11:54:40 -0800 
• Engine revision ae90085a84
• Dart version 2.10.4

[✓] Android 工具链 - 为 Android 设备开发(Android SDK 版本 30.0.2)

• Android SDK at /Users/raitotec/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[✓] Xcode - 为 iOS 和 macOS 开发 (Xcode 12.4)

• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.0

[✓] Android Studio(4.0版)

• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 50.0.1
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] 连接的设备(1 个可用)

• iPhone 12 Pro Max (mobile) 
• C5C673A3-40FA-497B-9FC5-08D68C859FCA 
• iOS
• com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)

pubspec.ymal

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.3
  flutter_local_notifications: ^4.0.0
  badges: ^1.1.6
  rflutter_alert: ^1.1.0
  toggle_switch: ^0.1.8
  flutter_rating_bar: ^3.2.0+1
  firebase_messaging: ^6.0.16

播客文件

# 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
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
    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['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
        end
      end
    end

吊舱安装

Analyzing dependencies
firebase_core: Using Firebase SDK version '6.33.0' defined in 'firebase_core'
firebase_messaging: Using Firebase SDK version '6.33.0' defined in 'firebase_core'
Downloading dependencies
Installing Firebase (6.33.0)
Installing FirebaseAnalytics (6.8.3)
Installing FirebaseCore (6.10.3)
Installing FirebaseCoreDiagnostics (1.7.0)
Installing FirebaseInstallations (1.7.0)
Installing FirebaseInstanceID (4.8.0)
Installing FirebaseMessaging (4.7.1)

标签: flutterfirebase-cloud-messaging

解决方案


推荐阅读