使用 Firebase Unity SDK 的 Firebase Xcode 链接器命令错误 [英] Firebase Xcode linker command error using Firebase Unity SDK

查看:29
本文介绍了使用 Firebase Unity SDK 的 Firebase Xcode 链接器命令错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firebase Unity SDK 1.1.1.统一 5.5.0p4Xcode 8.2.1

Firebase Unity SDK 1.1.1. Unity 5.5.0p4 XCode 8.2.1

从 Firebase 使用身份验证和数据库时,在 XCode 中构建项目时出现以下错误:

When using Authentication and Database from Firebase I get the following error when building the project in XCode :

架构 arm64 的未定义符号:
_OBJC_CLASS_$_FIRGoogleAuthProvider",引用自:objc-class-ref 在 libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
_OBJC_CLASS_$_FIRGitHubAuthProvider",引用自:objc-class-ref 在 libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
_OBJC_CLASS_$_FIREmailPasswordAuthProvider",引用自:objc-class-ref 在 libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
_OBJC_CLASS_$_FIRFacebookAuthProvider",引用自:objc-class-ref 在 libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
_OBJC_CLASS_$_FIRApp",引用自:libApp.a(app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o)
中的objc-class-ref_OBJC_CLASS_$_FIRAuth",引用自:objc-class-ref 在 libAuth.a(auth_ios_3c64a79cf1eb3f06f9309f4d8e91ee94.o)
_OBJC_CLASS_$_FIRTwitterAuthProvider",引用自:objc-class-ref 在 libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
_OBJC_CLASS_$_FIROptions",引用自:objc-class-ref 在 libApp.a(app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o) ld:符号不找到架构 arm64 clang:错误:链接器命令失败退出代码 1(使用 -v 查看调用)

Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRGoogleAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIRGitHubAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIREmailPasswordAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIRFacebookAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIRApp", referenced from: objc-class-ref in libApp.a(app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o)
"_OBJC_CLASS_$_FIRAuth", referenced from: objc-class-ref in libAuth.a(auth_ios_3c64a79cf1eb3f06f9309f4d8e91ee94.o)
"_OBJC_CLASS_$_FIRTwitterAuthProvider", referenced from: objc-class-ref in libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)
"_OBJC_CLASS_$_FIROptions", referenced from: objc-class-ref in libApp.a(app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

我是否遗漏了 XCode 中的某些内容?或者在 Unity 中有什么要检查的?

Do I miss something in XCode? Or have something to check in Unity?

谢谢!

推荐答案

我花了几天时间试图找出使用 Unity Cloud Build 进行构建与在本地进行构建时的错误.希望这可以帮助其他人!

I spent a couple of days trying to figure out the errors from building with Unity Cloud Build vs building locally. Hopefully this can help someone else!

只要您安装了 CocoaPods,这就会起作用.如果未安装 CocoaPods,则在为 iOS 构建后,Unity 控制台中将出现错误.除此之外,Firebase 提供的说明适用于 Unity 5.6 和 Xcode 8.3.

This just worked as long as you have CocoaPods installed. An error will appear in the Unity console after building for iOS if CocoaPods is not installed. Other than that, the instructions provided by Firebase worked fine with Unity 5.6 and Xcode 8.3.

CocoaPods 在 UCB 上不可用,但 Firebase 有一个非 CocoaPods 替代方案:https://firebase.google.com/docs/ios/setup#frameworks

CocoaPods is not available on UCB but Firebase has a non-CocoaPods alternative: https://firebase.google.com/docs/ios/setup#frameworks

手动添加框架

这些说明假设使用原生 iOS 构建,但您可以简单地将您需要的框架拖入 Assets/Plugins/iOS/Firebase 而不是 Xcode 项目.Unity 会在构建时将这些框架添加到 Xcode 项目中.

The instructions are assuming a native iOS build but you can simply drag the frameworks you need into Assets/Plugins/iOS/Firebase instead of into an Xcode project. Unity will add those frameworks to the Xcode project on build.

添加链接器标志

您需要手动将 -ObjC 添加到其他链接标志中.出于某种原因,它出现在我本地的 Xcode 项目中,但没有出现在 UCB 进行构建时.创建一个类似于 maros 提到的后期处理脚本:https://forum.unity3d.com/threads/problem-building-ios-app-with-cloud-build-using-google-analytics.390803/#post-2549911

You will need to manually add -ObjC into Other Link Flags. For some reason it showed up in my local Xcode project but not when UCB made the build. Create a post process script much like maros mentioned: https://forum.unity3d.com/threads/problem-building-ios-app-with-cloud-build-using-google-analytics.390803/#post-2549911

你需要像这样添加-ObjC:

proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

如果您不添加此部分,UCB 可能仍会创建构建,但尝试创建 FirebaseAuth 后游戏将立即崩溃,因为它将引用由于缺少 -ObjC 而未包含的扩展/类别方法 标志.

If you do not add this part, UCB may still create a build but the game will crash immediately after trying to create FirebaseAuth as it will reference an extension/category method that was not included due to the missing -ObjC flag.

添加其他必需的框架和库

根据您使用的 Firebase 功能,您可能需要不同的额外框架或库.例如,我使用了 FirebaseDatabase,虽然文档没有提到这一点,但 Xcode 抱怨链接器错误,需要我添加 libicucore.tbd.

Depending on which Firebase features you are using, you may need different additional frameworks or libs. For example I had used FirebaseDatabase and while the docs did not mention this, Xcode complained about a linker error that required me to add libicucore.tbd.

我认为解决这个问题的最好方法是在本地卸载 CocoaPods,然后让 Unity 创建 Xcode 项目,这样我就可以更准确地表示 UCB 会体验到什么.这部分可能需要一些试验和错误以及谷歌搜索来找出链接器错误所指的框架或库.只需尝试在本地构建 Xcode 项目,您就会收到链接器错误(如果有).

The best way I could think to solve this was uninstall CocoaPods locally and then have Unity create the Xcode project so that I could get a more accurate representation of what UCB would experience. This part may take some trial and error as well as Googling to figure out which framework or lib the linker error is referring to. Just try to build the Xcode project locally and you will get the linker errors if any.

我补充说:

List<string> frameworks = new List<string>() {
    "AdSupport.framework",
    "CoreData.framework",
    "SystemConfiguration.framework",
    "libz.dylib",
    "libsqlite3.dylib",
    "libicucore.tbd"
};

手动移动 GoogleServices-Info.plist

另一个奇怪的是,UCB 没有将 GoogleServices-Info.plist 移动到 Xcode 项目中.必须有一些其他脚本不在本地运行的 UCB 上运行.在添加链接器标志和框架的后期处理脚本中,您还可以将 GoogleServices-Info.plist 移动到 Xcode 项目目录中,然后将其添加到包中.

Another oddity is that UCB did not move the GoogleServices-Info.plist into the Xcode project. There must be some other script that is not running on UCB that does run locally. In the post process script where you add the linker flag and frameworks, you can also move the GoogleServices-Info.plist into the Xcode project directory and then add it to the bundle.

首先移动文件:

if (!File.Exists(path + "/GoogleService-Info.plist"))
{
    FileUtil.CopyFileOrDirectory ("GoogleService-Info.plist", path + "/GoogleService-Info.plist");
}

然后将其添加到构建中:

Then add it to the build:

string guid = proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist");
proj.AddFileToBuild(target, guid);

应该就是这样.如果我在添加更多 Firebase 功能时遇到任何其他问题,我会更新.目前我正在使用身份验证、数据库和分析.

And that should be it. I will update if I run into any other issues as I add more Firebase features. Currently I am using Auth, Database, and Analytics.

这篇关于使用 Firebase Unity SDK 的 Firebase Xcode 链接器命令错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆