默认应用程序已配置

5 xcode objective-c firebase podfile

我知道有关该主题的讨论很多,但没有答案有助于解决我的错误

由于未捕获的异常“com.firebase.core”而终止应用程序,原因:“默认应用程序已配置。”

我尝试过:

   - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
    {
        if ([FIRApp defaultApp] == nil) {
            [FIRApp configure];
        }

        self.viewController = [[MainViewController alloc] init];
        return [super application:application didFinishLaunchingWithOptions:launchOptions];
    }

@end
Run Code Online (Sandbox Code Playgroud)

默认应用程序应仅在nil时配置。但这不起作用。似乎有什么问题?

这是我的Podfile

# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'

target 'com.notificationTest.fcm' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

   # Pods for com.notificationTest.fcm
   pod 'Firebase/Core'
   pod 'Firebase/Messaging'

end
Run Code Online (Sandbox Code Playgroud)

小智 2

首先,检查您的项目中是否意外地实现了 FirebaseApp.configure() 两次

或尝试下面

在 AppDelegate.swift 中重写以下方法:

override init() { FirebaseApp.configure() } 
Run Code Online (Sandbox Code Playgroud)

在 ViewController.swift 的 viewDidLoad() 方法中,编写以下代码:

if FirebaseApp.app() == nil { FirebaseApp.configure()}
Run Code Online (Sandbox Code Playgroud)

[从另一种语言 swift 分享]