简体   繁体   English

在Swift 4.x中导入Facebook SDK失败

[英]Failed importing Facebook SDK in Swift 4.x

I've tried to import Facebook SDK for App Events and tracking of App Installs through Facebook ADS and it's being impossible to do it. 我已经尝试通过应用程序事件导入Facebook SDK,并通过Facebook ADS跟踪应用程序安装,但这是不可能的。

I've done it with CocoaPods using: 我已经用CocoaPods完成了:

pod 'FacebookCore'

as the Facebook official tutorial says. 正如Facebook官方教程所说。

After that, Facebook Analytics has detected me as a New unique user, so that is great 👍. 之后, Facebook Analytics(分析)将我检测为新的唯一用户,这太好了。

The problem is when I try to add an APP Event like so: 问题是当我尝试添加如下所示的APP事件时:

AppEventsLogger.log("Opened App Main VC");

And then this ERROR 🔴 appears: 然后出现此错误 🔴:

Use of unresolved identifier 'AppEventsLogger'

Apart from this, also it's not detecting AppEventsLogger in the AppDelegate with the same error: 除此之外,它也没有在AppDelegate中检测到具有相同错误的AppEventsLogger

AppEventsLogger.activate(application)

I've imported in the VC and in the AppDelegate this modules/libraries: 我已经在VCAppDelegate中导入了以下模块/库:

import FacebookCore //in theory is just this one
import FBSDKCoreKit

So any tip or help is very welcomed! 因此,任何提示或帮助都非常欢迎! 😊 😊

Two Imports 两次进口

import FacebookCore
import FBSDKCoreKit

In AppDelegate 在AppDelegate中

 func applicationDidBecomeActive(_ application: UIApplication) {
    AppEvents.activateApp()
}

When you want to log an event: 当您想记录事件时:

AppEvents.logEvent(AppEvents.Name.init(rawValue: "Opened App Main VC"))

For another type of AppEvents, you can refer to this 对于其他类型的AppEvent,您可以参考

The problem is AppEventsLogger is changed to AppEvents . 问题是AppEventsLogger更改为AppEvents So change the name of AppEventsLogger and it will work fine. 因此,更改AppEventsLogger的名称即可正常运行。 This is a new update in Facebook sdk. 这是Facebook SDK中的新更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM