Swift 对 firebase-cpp-sdk 的绑定,大致模仿 iOS API。它既是对 C++ 互操作的探索,也是一种从 Swift 在 Windows 上使用 Firebase 的方法。
Firebase 的 Swift 接口构建于 Firebase C++ SDK 之上。 因此,该软件包要求 C++ SDK 可用并分发给客户端。 该软件包期望 Firebase SDK 位于源树的根目录下的 third_party/firebase-development/usr
中。
截至 2023-08-10,Firebase SDK 需要进行一些更改以支持 Swift/C++ 互操作。 此更改可在此处找到:此处。 此更改已作为 firebase/firebase-cpp-sdk#1414 向上游发送。
firebase-windows-amd64.zip
或 firebase-windows-arm64.zip
,具体取决于您要构建的体系结构。md third_party\firebase-development
以创建目录,我们将在其中提取刚刚下载的 Firebase C++ SDK 版本。third_party\firebase-development
目录中。Examples\FireBaseUI\Resources\google-services.json
文件,以包含来自 Firebase 的正确值。提示
将 google-services.json
文件标记为假定未更改可能很有用,这样您就不会意外地提交包含真实凭据的文件。 为此,您可以运行以下命令:git update-index --assume-unchanged .\Examples\FireBaseUI\Resources\google-services.json
假设 Firebase 的构建版本位于顶层的 third_party\firebase-development\usr
下,则该软件包应使用以下命令作为标准 SPM 软件包构建:
swift build
演示应用程序作为示例包含在内,并且由于需要部署辅助文件,因此需要进行一些额外的设置。
swift build --product FireBaseUI
copy Examples\FireBaseUI\Info.plist .build\debug\
copy Examples\FireBaseUI\FireBaseUI.exe.manifest .build\debug\
swift run
假设 Firebase 的构建版本位于顶层的 third_party\firebase-development\usr
下,则该软件包应使用以下命令作为标准 CMake 软件包构建:
cmake -B out -G Ninja -S .
随后,您应该能够通过直接启动演示应用程序来运行它,如下所示:
.\out\bin\FireBaseUI.exe