首页 文章

使用Firebase Unity SDK的Firebase Xcode链接器命令错误

提问于
浏览
10

Firebase Unity SDK 1.1.1 . Unity 5.5.0p4 XCode 8.2.1

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

未定义架构arm64符号: “_OBJC_CLASS _ $ _ FIRGoogleAuthProvider”,从引用:objc级-REF IN libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o) “_OBJC_CLASS _ $ _ FIRGitHubAuthProvider”,从引用:在libAuth.a objc级-REF(credential_ios_ef8c3cf45c3329a5e5902f99026c639a的.o) “OBJC_CLASS _ $ _ FIREmailPasswordAuthProvider”,从引用:在libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o) “OBJC_CLASS _ $ _ FIRFacebookAuthProvider” objc级-REF,从引用:在libAuth.a(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o objc级-REF)“ OBJC_CLASS _ $ _ FIRApp“,引自:libApp.a中的objc-class-ref(app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o)” OBJC_CLASS _ $ _ FIRAuth“,引用自:libAuth.a中的objc-class-ref(auth_ios_3c64a79cf1eb3f06f9309f4d8e91ee94.o)” OBJC_CLASS _ $ _ FIRTwitterAuthProvider“ ,引用自:libAuth.a中的objc-class-ref(credential_ios_ef8c3cf45c3329a5e5902f99026c639a.o)“ OBJC_CLASS _ $ _ FIROptions”,引自: libApp.a中的objc-class-ref(app_ios_c76c7d869e568a9b561ea55e25a7dcc0.o)ld:找不到架构arm64 clang的符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)

我在XCode中想念一下吗?或者在Unity中检查一下?

谢谢!

8 回答

  • 4

    我花了几天的时间试图弄清楚使用Unity Cloud Build构建本地构建的错误 . 希望这可以帮助别人!

    本地建筑

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

    使用Unity Cloud Build构建

    CocoaPods不适用于UCB,但Firebase有非CocoaPods替代方案:https://firebase.google.com/docs/ios/setup#frameworks

    Add Frameworks Manually

    这些说明假设是原生iOS构建,但您只需将所需的框架拖到Assets / Plugins / iOS / Firebase而不是Xcode项目中 . Unity将在构建时将这些框架添加到Xcode项目中 .

    Add Linker Flag

    您需要手动将 -ObjC 添加到其他链接标志中 . 出于某种原因,它出现在我的本地Xcode项目中,但不是在UCB进行构建时 . 创建一个后期处理脚本,就像提到的maros一样: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 标志而未包含的扩展/类别方法 .

    Add Other Required Frameworks and Libraries

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

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

    我补充说:

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

    Manually Move GoogleServices-Info.plist

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

    首先移动文件:

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

    然后将其添加到构建中:

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

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

  • 5

    我有同样的问题,只是修复它 .

    找到Podfile文件并在文本编辑器中打开它 . 去掉

    ,:integrate_targets => false

    在第二行所以它说:安装! '的CocoaPods'

    然后在平台之后添加一个新行:ios ...

    use_frameworks!

    然后打开终端屏幕并转到该项目的目录 . 输入“pod install”并输入 . 如果一切顺利,将创建工作区文件并显示一条消息,您应该在Xcode中打开工作区而不是项目 . 所以在xcode中关闭项目并打开projectname.xcworkspace文件 . 现在Xcode将打开工作区,您将能够运行该项目 . 您可能必须将部署目标调整为8.0 . 希望这对你有用

  • 4

    首先,感谢所有人分享你的(努力)工作!

    关于这个问题已经说了很多,但它花了我一个时间和 lot 的试验和错误来收集SO和Unity论坛上的所有部分,所以我将发布我最终解决的解决方案,最终解决了所有问题,使用统一 Cloud 构建/ Unity 5.6.0f3 / Xcode 8.0,该项目仅使用firebase分析包

    UNITY CLOUD BUILD的解决方案

    • 从Unity>资产>播放服务解析器> iOS解析器>设置完全禁用cocoapods(取消选中"Podfile Generation"和"Auto Install Cocoapod Tools in Editor",选择"None - do not integrate Cocoapods")p

    • 将GoogleServices-Info.plist放在Unity "Assets"文件夹中

    • PostBuildProcessor方法:


    private static void ProcessPostBuild (BuildTarget buildTarget, string path)
    {
        // Only perform these steps for iOS builds
        #if UNITY_IOS
    
        Debug.Log ("[UNITY_IOS] ProcessPostBuild - Adding Google Analytics frameworks.");
    
        // Go get pbxproj file
        string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
    
        // PBXProject class represents a project build settings file,
        // here is how to read that in.
        PBXProject proj = new PBXProject ();
        proj.ReadFromFile (projPath);
        // This is the Xcode target in the generated project
        string target = proj.TargetGuidByName("Unity-iPhone");
    
        proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
        proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-v");
        proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
    
        if (!File.Exists(path + "/GoogleService-Info.plist"))
        {
            FileUtil.CopyFileOrDirectory("Assets/GoogleService-Info.plist", path + "/GoogleService-Info.plist");
        }
        string guid = proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist");
        proj.AddFileToBuild(target, guid);
    
        // List of frameworks that will be added to project
        List<string> frameworks = new List<string>() {
            "AddressBook.framework",
            "AdSupport.framework",
            "CoreData.framework",
            "SystemConfiguration.framework",
        };
    
        // Add each by name
        frameworks.ForEach((framework) => {
            proj.AddFrameworkToProject(target, framework, false);
        });
    
        // List of frameworks that will be added to project
        List<string> usrLibFrameworks = new List<string>() {
            "libsqlite3.tbd",
            "libz.tbd",
            "libicucore.tbd",
        };
    
        // Add each by name
        usrLibFrameworks.ForEach((framework) => {
            proj.AddFileToBuild(target, proj.AddFile("usr/lib/"+ framework, "Frameworks/" + framework, PBXSourceTree.Sdk));
        });
    
    
        // Write PBXProject object back to the file
        proj.WriteToFile (projPath);
    
        #endif
    }
    

    PS很疯狂,firebase unity sdk要求这样的黑客工作(UCB对我们来说是绝对的要求,我猜对于大多数多平台移动开发人员而言)我希望所有这些解决方法很快就会毫无用处,但是判断所有这些问题都来自于官方firebase开始支持Unity,我不会太在意它

  • 0

    我只想弄明白,只需在Unity创建的pod文件中使用旧版本就可以了

    目标'Unity-iPhone'做pod'Firebase / Analytics','3.17.0'pod'Firebase / Auth','3.17.0'pod'Firebase / Core','3.17.0'pod'Google-Mobile-Ads -SDK','7.13'结束

    ///注意: //

    不要忘记在(Google-Mobile-Ads-SDK)的构建设置中将启用模块(c和Objective-c)设置为yes

    然后从终端打开文件夹并运行: - > pod install以更新pod

    :)

  • 2

    Building Unity app with Firebase framework locally with Xcode:

    这完全与iOS SDK版本有关 . 这个答案有部分解决方案:https://stackoverflow.com/a/41908040/8063631

    在Mac环境中工作 .

    在Unity中构建iOS时 . 请务必先检查:资产 - > iOS解析器 - >设置

    • Cocoapods整合

    • Xcode工作区 - 将可可 beans 荚添加到Xcode工作区

    • 在编辑器中自动安装Cocoapods工具

    构建到iOS并打开.workspace文件 .

    然后转到Pods - > Podfile并添加过去的发行版本(3.7.0),因为4.0.0启动时出错 .

    target 'Unity-iPhone' do
        pod 'Firebase/Auth'
        pod 'Firebase/Core'
    end
    

    通过(例如......)

    target 'Unity-iPhone' do
        pod 'Firebase/Auth', '3.7.0'
        pod 'Firebase/Core', '3.7.0'
    end
    

    关闭xCode IDE以避免冲突,然后安装Cocoapods(如果你还没有)(https://guides.cocoapods.org/using/getting-started.html):

    检查:

    pod --version
    

    安装时间:

    sudo gem install cocoapods
    

    通过运行终端转到项目文件夹并键入:

    pod install
    

    它将删除当前的版本,并将其替换为3.7.0

    打开xCode并按产品 - >清洁和产品 - >构建

  • 1

    我有同样的问题,花了几个小时我得到了主要问题 .

    它是podfile库定义的特定版本 .

    target 'Unity-iPhone' do
        pod 'Firebase/Auth', '4.10.0'
        pod 'Firebase/Core', '4.10.0'
    end
    

    当unity构建iOS项目的podfile时,他们定义了他们最新的库版本 . 但是当从xcode / terminal尝试从GIT更新pod库并且特定版本不可用时,它无法更新并显示此错误 .

    Solution is simple just don't need to define the specific version. pod will update the GIT's latest version.

    target 'Unity-iPhone' do
        pod 'Firebase/Auth'
        pod 'Firebase/Core'
    end
    
  • 1

    CocoaPods

    CocoaPods是iOS / macOS项目的依赖管理器 . 它用于为项目安装外部框架/库 .


    Building Unity app with Firebase framework locally with Xcode

    您需要在系统上安装cocoapods:https://guides.cocoapods.org/using/getting-started.html#toc_3


    Building Unity app with Firebase framework on Unity Build Cloud:

    对于在Unity Build Cloud服务器上遇到此问题的用户 .

    根据这个论坛帖子:https://forum.unity3d.com/threads/build-failed-cocoapods.421286/不支持cocoapods . (甚至可能没有安排开发) .

    Cocoapods负责在Xcode项目中为您的iOS项目设置所有引用的库 . 由于Unity Build Cloud不支持它们,因此您需要手动执行此操作 .

    // ObjC - needed for Firebase proj.AddBuildProperty (target, "OTHER_LDFLAGS", "-ObjC");

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

    保存Unity项目,现在iOS Unity Build Cloud应该可以运行

  • 0

    我有这个问题,并通过更新pods安装修复了一种方法是清除本地缓存的副本并重新安装它,另一种方法是强制安装来自在线源

    值得一提的是,IOS的建设成功了

    构建完成,结果为'成功'

    但安装pod时出错

    解决方案之一

    在mac终端上将目录更改为应包含 Podfile 的构建文件夹

    执行以下

    $ pod repo remove master
    $ pod install --repo-update
    

    从unity重建项目应自动安装 pods

    其他解决方案

    从GitHub安装

    有关详细信息,请参阅Firebase pods

    对于从5.0.0开始的发行版,每个发行版的源代码也部署到CocoaPods master并可通过标准CocoaPods Podfile语法 .

    这些说明可用于访问其他分支,标记或提交中的Firebase存储库 .

    背景

    有关覆盖pod源位置的说明和选项,请参阅Podfile语法参考 .

    逐步的源Pod安装说明

    对于iOS,将以下行的子集复制到 Podfile

    pod 'Firebase' # To enable Firebase module, with@import Firebasesupport pod 'FirebaseCore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseDatabase', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseFirestore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseFunctions', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseMessaging', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseStorage', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'

    对于macOS和tvOS,请复制以下内容的一部分: pod 'FirebaseCore', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseAuth', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseDatabase', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0' pod 'FirebaseStorage', :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => '5.0.0'

    1-确保你至少拥有CocoaPods版本1.4.0 - pod --version .

    2-删除不需要的任何组件的pod,但必须始终包含FirebaseCore .

    3-将标记更新到最新的Firebase版本 . 见release notes

    4-运行pod更新 .

相关问题