gpt4 book ai didi

swift - 将我的项目与 firebase 连接以发送推送通知时出错

转载 作者:行者123 更新时间:2023-11-28 15:33:06 25 4
gpt4 key购买 nike

我正在尝试将我的应用程序连接到 firebase 以发送通知,但出现错误:

  "_OBJC_CLASS_$_FIRApp", referenced from:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

在General Capabilities中没有任何错误。在相同的代码中没有任何错误,但是当我构建并运行时出现此错误。创建证书时也没有任何错误。 Here is how the errror is look like .请帮忙!

这是我写的一段代码:

//
// AppDelegate.swift
// COAP
//
// Created by Azamat Bolegenov on 23.05.17.
// Copyright © 2017 Azamat Bolegenov. All rights reserved.
//

import UIKit
import CoreData
import FirebaseCore
import FirebaseMessaging


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

FirebaseApp.configure()

let notificationTypes: UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound]
let notificationSettings = UIUserNotificationSettings(types: notificationTypes, categories: nil)
application.registerForRemoteNotifications()
application.registerUserNotificationSettings(notificationSettings)
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
print("MessageID:: \(userInfo["gcm_message_id"]!)")
print(userInfo)
}




func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

最佳答案

转到 Build Settings > Other Linker Flags > on a new line $(inherited)。

执行 Cmd+Ctrl+K 进行清理,然后构建

关于swift - 将我的项目与 firebase 连接以发送推送通知时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44563391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com