简体   繁体   English

如何将 Firebase Functions v8 添加到 Swift iOS 项目并在 httpsCallable 中使用 Codable?

[英]How to add Firebase Functions v8 to a Swift iOS project and use Codable in httpsCallable?

I have a Swift 5.5 iOS project that already contains Firebase 7.x and uses Firebase Functions.我有一个 Swift 5.5 iOS 项目,它已经包含 Firebase 7.x 并使用 Firebase 函数。 I just upgraded to 8.13.0, because I want to use Codable support in Firebase Functions.我刚刚升级到 8.13.0,因为我想在 Firebase Functions 中使用Codable支持。

I added Firebase through the Swift Package manager and included Firebase Functions in my source code using:我通过 Firebase 通过 Swift Package 管理器添加了 Firebase 并使用以下代码在我的源代码中包含了 Firebase 函数:

import FirebaseFunctions

However, when I want to call:但是,当我想打电话时:

  func httpsCallable<Request: Encodable,
    Response: Decodable>(_ name: String,
                         requestAs: Request.Type = Request.self,
                         responseAs: Response.Type = Response.self)

I get an error saying that it doesn't find this method.我收到一条错误消息,指出它找不到此方法。

Upon inspecting the packages, I discovered that the function I want to call is defined in FirebaseFunctionsSwift in a file called Callable+Codable .检查包后,我发现我想调用的 function 是在FirebaseFunctionsSwift中一个名为Callable+Codable的文件中定义的。

This exists in my project as you can see:如您所见,这存在于我的项目中:

在此处输入图像描述

However when I add import FirebaseFunctionsSwift to my source file I get the following error:但是,当我将import FirebaseFunctionsSwift添加到我的源文件时,出现以下错误:

No such module 'FirebaseFunctionsSwift'

How can I solve this problem?我怎么解决这个问题?

Add FirebaseFunctionsSwift-Beta framework to the build target:将 FirebaseFunctionsSwift-Beta 框架添加到构建目标:

在此处输入图像描述

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

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