我试图在我的Flutter应用程序中添加Firebase支持,但遇到一个问题,我在互联网上搜索了很多次+堆栈溢出,但根本没有任何解决方案。
有人说这是Swift的问题,但我不确定。
以下是我在尝试构建应用时从Android Studio获取的日志。
Launching lib/main.dart on iPhone XR in debug mode...
Running pod install...
Starting Xcode build...
Xcode build done. 14,4s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target.
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
/Users/ardacebi/Desktop/histic/histic/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'firebase_admob/FirebaseAdMobPlugin.h' file not found
#import <firebase_admob/FirebaseAdMobPlugin.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Could not build the application for the simulator.
Error launching application on iPhone XR.
这是在我添加Firebase FlutterFire插件(我需要时全部使用)阅读本指南之后发生的:
你们有什么解决方案吗?谢谢。
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Runner' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Runner
pod 'Firebase'
pod 'Firebase/Core'
end
name: histic
description: Scientific discussion platform.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.3.0
firebase_admob: ^0.8.0
firebase_analytics: ^0.3.0
firebase_auth: ^0.8.0+1
firebase_database: ^2.0.0
firebase_messaging: ^3.0.0
firebase_dynamic_links: ^0.2.0
firebase_ml_vision: ^0.3.0
firebase_performance: ^0.1.0
firebase_remote_config: ^0.1.0
firebase_storage: ^2.0.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.io/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
import UIKit
import Flutter
import Firebase
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
答案 0 :(得分:2)
这种情况是由于Pod的安装中断引起的。 因此,首先您需要重新安装二进制文件,然后运行以下命令清除项目目录中的项目缓存:
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
然后再次安装,直到结束:
pod install
答案 1 :(得分:1)
对我来说,我删除了ios / Flutter / Flutter.framework文件夹,然后再次安装pods pod install,然后就可以了。