在 Xcode for iOS 上构建时发生 Firebase 错误

问题描述

我在 xcode 中构建应用程序时遇到了一些麻烦,但在 Unity 中构建到 android 工作正常。我已经搜索了所有其他解决方案都没有帮助我完成构建。我不使用任何 pod,只是将目标切换到 iOS,签名并尝试构建。 xcode 给我的错误是这样的:

显示最近的错误

使用配置 ReleaseForRunning 构建项目 Unity-iPhone 的目标 UnityFramework 警告:不推荐使用 OpenGLES。考虑迁移到 Metal。 (在项目“Unity-iPhone”的目标“UnityFramework”中)

Ld /Users/schrodingerlab/Library/Developer/Xcode/DerivedData/Unity-iPhone-cznkgmrdhbgorsbwisensbubkxok/Build/Products/ReleaseForRunning-iphoneos/UnityFramework.framework/UnityFramework 正常(在项目“Unity-iPhone”的目标“UnityFramework”中) ) cd /Users/schrodingerlab/Thermomix_40/buildenios6 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target arm64-apple-ios12.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS。平台/开发人员/SDKs/iPhoneOS14.4.sdk -L/Users/schrodingerlab/Library/Developer/Xcode/DerivedData/Unity-iPhone-cznkgmrdhbgorsbwisensbubkxok/Build/Products/ReleaseForRunning-iphoneos -L/Users/schrodingerlab/Thermoenios库 -L/Users/schrodingerlab/Thermomix_40/buildenios6/Libraries/com.ptc.vuforia.engine/Vuforia/Plugins/iOS -L/Users/schrodingerlab/Thermomix_40/buildenios6/Libraries/Plugins/iOS/Firebase -F/Users/ schrodingerlab/Library/Developer/Xcode/DerivedData/Unity-iPhone-cznkgmrdhbgorsbwisensbubkxok/Build/Products/ReleaseForRunning-iphoneos -F/Users/schrodingerlab/Thermomix_40/buildenios6/Frameworks/com.unity.ads/iOS/Fugins schrodingerlab/Thermomix_40/buildenios6/Frameworks/com.ptc.vuforia.engine/Vuforia/Plugins/iOS -filelist /Users/schrodingerlab/Li brary/Developer/Xcode/DerivedData/Unity-iPhone-cznkgmrdhbgorsbwisensbubkxok/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityFramework.LinkFileList -install_name @rpath/UnityFramework。 framework/UnityFramework -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -map -Xlinker /Users/schrodingerlab/Library/Developer/Xcode/DerivedData/Unity-iPhone-cznkgmrdhbgorsbwisensbubkxok/Build/Intermediates.noindex/Unity-iPhone.build/ ReleaseForRunning-iphoneos/UnityFramework.build/UnityFramework-LinkMap-normal-arm64.txt -dead_strip -Xlinker -object_path_lto -Xlinker /Users/schrodingerlab/Library/Developer/Xcode/DerivedData/Unity-iPhone-cznkgmrdhbgorsbwisensbubkxok/Buildindex/Interface Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityFramework_lto.o -fembed-bitcode-marker -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -lc++ -weak_framework CoreMotion -weak -l系统 -liPhone -lib -framework Security -framework MediaToolBox -framework CoreText -framework AudioToolBox -weak_framework AVFoundation -framework AVKit -framework CFNetwork -framework CoreGraphics -framework CoreMedia -weak_framework CoreMotion -framework CoreVideo -framework Foundation -framework OpenAL -framework OpenGLES -framework QuartzCore -framework SystemConfiguration -framework UIKit -liconv.2 -lil2cpp -framework UnityAds -lVuforiaWrapper -framework Vuforia -lFirebaseCppMessaging -lFirebaseCppAnalytics -lFirebaseCppApp -framework AdSupport -framework CoreTelephony -framework StoreKit -framework CoreLocation -framework StoreKit -framework CoreLocation -weak_framework_framework_framework -dependency_info -Xlinker /Users/schrodingerlab/Library/Developer/Xcode/DerivedData/Unity-iPhone-cznkgmrdhbgorsbwisensbubkxok/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/Objects-normal/arm64/ cy_info.dat -o /Users/schrodingerlab/Library/Developer/Xcode/DerivedData/Unity-iPhone-cznkgmrdhbgorsbwisensbubkxok/Build/Products/ReleaseForRunning-iphoneos/UnityFramework.framework/UnityFramework

架构 arm64 的未定义符号: “OBJC_CLASS$_FIRConfiguration”,引用自: libFirebaseCppApp.a(log_ios_dd26aec5b8537064a4c15d38b58b4640.o)中的objc-class-ref “OBJC_CLASS$_FIRMessaging”,引用自: libFirebaseCppMessaging.a(messaging_231c52c311096cfce13e67fa91eb9ac5.o)中的objc-class-ref “OBJC_CLASS$_FIRApp”,引用自: libFirebaseCppApp.a(app_ios_814e1620d4f88024cea4bade26623a67.o)中的objc-class-ref “OBJC_CLASS$_FIROptions”,引用自: libFirebaseCppApp.a(app_ios_814e1620d4f88024cea4bade26623a67.o)中的objc-class-ref “_MuskGetLocaleRegion”,引用自: _DeviceCountryProvider_Awake_mEE95CC492427159A08D423192B51472917D33011 在 Assembly-CSharp2.o _DeviceCountryProvider_MuskGetLocaleRegion_mDEF69019B1CC4B23AAB2F05C013AAD759104CA9C 在 Assembly-CSharp2.o (也许你的意思是:_DeviceCountryProvider_MuskGetLocaleRegion_mDEF69019B1CC4B23AAB2F05C013AAD759104CA9C) ld:找不到架构 arm64 的符号 clang:错误链接器命令失败,退出代码为 1(使用 -v 查看调用

构建失败 17/3/21,19:41 151.1 秒

我认为 arm64 库有一个错误提示,我尝试手动包含它,但仍然得到了 MuskGetLocaleRegion。

感谢您的宝贵时间!

解决方法

看起来您要么跳过了 Unity 中的 CocoaPods 步骤,要么禁用了 Firebase Unity SDK 的某些核心功能。您也可能在将 Firebase 与另一个库混合时遇到问题。我会为您提供一些快速调试技巧,以及如果问题更大,如何提交错误报告。

首先,由于这是一个新项目,请确保您的 Firebase Unity SDK 为 updated to the latest (currently 7.1.0)。

接下来,您需要确保 CocoaPods 已正确安装。这应该会自动发生,但您不妨检查一下。如果您键入 pod,您应该会看到除“未找到命令”之外的一些输出。如果你没有它,你总是可以导航到“Assets>External Dependency Manager>iOS Resolver>Install Cocoapods”来这样做: Screenshot showing "Install Cocoapods" at "Assets>External Dependency Manager>iOS Resolver"

您也可以选择在 this guide 后直接安装 CocoaPods。最后,我们确实发现有时 CocoaPods 需要在某些操作系统升级时卸载/重新安装(特别是迁移到 Catalina)。这可能不适用,但如果您继续遇到问题,您可以尝试卸载。

Firebase 将正确的 Pod 文件与构建的 Unity 游戏相关联的机制称为 "External Dependency Manager for Unity" (EDM4U)。可能值得打开“iOS Resolver Settings”(在您找到“Install Cocoapods”的同一菜单中)并重置为默认值。为方便起见,我附上了我的设置页面的屏幕截图: Screenshot of my "iOS Resolver Settings". The following options are selected. Podfile Generation: true. Cocoapods Integration: Xcode Workspace. Use Shell to Execute Cocoapod Tool: true. Auto Install Cocoapod Tools in Editor: true. Add use_frameworks! to Podfile: true. Link frameworks statically: false. Always add the main target to Podfile: true. Allow the same pod to be in multiple targets: true. Enable Analytics Reporting: true. Verbose Logging: false. Use project settings: true.

由于您之前遇到过问题,现在是删除之前生成的项目的好时机。然后,您可以从“构建设置”窗口中单击“构建并运行”。 Unity 应该生成你的 xcodeproj,生成一个 Podfile,使用 Podfile 生成一个 xcworkspace,然后为你打开 xcworkspace。

从这里构建和运行应该可行。

有时人们仍然会遇到问题。这里有一些变动的部分:Unity 版本、Cocoapods 版本、Firebase 版本和依赖管理器版本,更不用说使用 EDM4U 或做自己的自定义工作来集成的任何其他库(值得注意的是,我们已经看到几乎每个工具都可以“制作”来自 Windows 的 iOS 版本”无法工作)。

因此,除了确保您的 Podfile 与您对 the iOS getting started guide 的预期大致相同之外,更新 Cocoapods 和更新 Firebase(不要遵循 iOS 指南,Unity 的不同之处在于您应该遵循 { {3}}),您可能需要跟进 Unity guide。这样做时,首先要做的是验证您的设置是否适用于您使用的 Firebase 产品的 the public issue tracker(它看起来像错误日志中的 quickstart?)。