You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS集成ARCore Geospatial Unity库与Firebase冲突崩溃求助

Firebase与Unity作为库集成的冲突崩溃问题

我有一个使用Firebase的iOS应用MyApp,需要集成一个基于ARCore Geospatial的“Unity作为库”模块。尝试多种构建策略后,运行时始终出现大量Firebase冲突日志,最终崩溃。单独运行Unity框架一切正常,移除MyApp中的Firebase后也能正常运行,但生产环境无法移除Firebase。请问是否有其他人遇到过相同问题?


重复类定义警告

大量类似如下错误:

objc[8956]: Class FIRInstallationsErrorUtil is implemented in both /private/var/containers/Bundle/Application/EE0FB4F1-DFB7-4A15-8781-DE1336275BEA/Loquis.app/Frameworks/UnityFramework.framework/UnityFramework (0x10bcbd960) and /private/var/containers/Bundle/Application/EE0FB4F1-DFB7-4A15-8781-DE1336275BEA/Loquis.app/Loquis (0x101cd0c38). One of the two will be used. Which one is undefined. objc[8956]: Class FIRInstallationsHTTPError is implemented in both /private/var/containers/Bundle/Application/EE0FB4F1-DFB7-4A15-8781-DE1336275BEA/Loquis.app/Frameworks/UnityFramework.framework/UnityFramework (0x10bcbd988) and /private/var/containers/Bundle/Application/EE0FB4F1-DFB7-4A15-8781-DE1336275BEA/Loquis.app/Loquis (0x101cd0c60). One of the two will be used. Which one is undefined.

Firebase未配置提示

随后出现:

10.19.1 - [FirebaseCore][I-COR000003] The default Firebase app has not yet been configured. Add `FirebaseApp.configure()` to your application initialization. This can be done in in the App Delegate's application(_:didFinishLaunchingWithOptions:)` (or the `@main` struct's initializer in SwiftUI).

最终崩溃日志

最终崩溃日志:

** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBLPromise HTTPBody]: unrecognized selector sent to instance 0x282f7ed30'
*** First throw call stack:
(0x198194870 0x1904b3c00 0x19822519c 0x1980d9ff8 0x19821ab10 0x1096bc7ec 0x1096bbf8c 0x1096596b4 0x1038e4f50 0x1038e6b34 0x1038eeba4 0x1038ef728 0x1038fc5f8 0x1038fbc2c 0x201b05964 0x201b05a04)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBLPromise HTTPBody]: unrecognized selector sent to instance 0x282f7ed30'
*** First throw call stack:
(0x198194870 0x1904b3c00 0x19822519c 0x1980d9ff8 0x19821ab10 0x1096bc7ec 0x1096bbf8c 0x1096596b4 0x1038e4f50 0x1038e6b34 0x1038eeba4 0x1038ef728 0x1038fc5f8 0x1038fbc2c 0x201b05964 0x201b05a04)
[0x125f6c800] Created session
[0x0] Releasing session
[0x125f6c800] Releasing session
Uncaught exception: NSInvalidArgumentException: -[FBLPromise HTTPBody]: unrecognized selector sent to instance 0x282f7ed30
(
    0   CoreFoundation                      0x000000019819487c B37A1273-B0C2-312E-9E0B-7143FB645C69 + 968828
    1   libobjc.A.dylib                     0x00000001904b3c00 objc_exception_throw + 60
    2   CoreFoundation                      0x000000019822519c B37A1273-B0C2-312E-9E0B-7143FB645C69 + 1560988
    3   CoreFoundation                      0x00000001980d9ff8 B37A1273-B0C2-312E-9E0B-7143FB645C69 + 204792
    4   CoreFoundation                      0x000000019821ab10 _CF_forwarding_prep_0 + 96
    5   UnityFramework                      0x00000001096bc7ec -[GDTCCTUploadOperation updateNextUploadTimeWithResponse:forTarget:] + 52
    6   UnityFramework                      0x00000001096bbf8c __54-[GDTCCTUploadOperation uploadBatch:toTarget:storage:]_block_invoke + 56
    7   UnityFramework                      0x00000001096596b4 __56-[FBLPromise chainOnQueue:chainedFulfill:chainedReject:]_block_invoke.18 + 52
    8   libdispatch.dylib                   0x00000001038e4f50 _dispatch_call_block_and_release + 32
    9   libdispatch.dylib                   0x00000001038e6b34 _dispatch_client_callout + 20
    10  libdispatch.dylib                   0x00000001038eeba4 _dispatch_lane_serial_drain + 1368
    11  libdispatch.dylib                   0x00000001038ef728 _dispatch_lane_invoke + 408
    12  libdispatch.dylib                   0x00000001038fc5f8 _dispatch_root_queue_drain_deferred_wlh + 328
    13  libdispatch.dylib                   0x00000001038fbc2c _dispatch_workloop_worker_thread + 444
    14  libsystem_pthread.dylib             0x0000000201b05964 _pthread_wqthread + 288
    15  libsystem_pthread.dylib             0x0000000201b05a04 start_wqthread + 8
)
libc++abi: terminating due to uncaught exception of type NSException

objc[8956]: Class _TtGCs18_DictionaryStorageSSGV20FirebaseCoreInternal13WeakContainerCS0_16HeartbeatStorage__$ is implemented in both ?? (0x13b525b28) and /usr/lib/swift/libswiftCore.dylib (0x1e91273a0). One of the two will be used. Which one is undefined.

解决方案

这类问题本质是主App和UnityFramework重复引入Firebase相关库,导致符号冲突,进而引发运行时异常。以下是经过验证的解决步骤:

  • 统一Firebase版本:确保主App和Unity项目使用的Firebase SDK版本完全一致,建议都用最新稳定版,版本不匹配会加剧冲突。
  • 移除Unity侧Firebase依赖:打开Unity项目,删除所有Firebase包和插件;在Player Settings中清空Firebase相关配置,重新导出Unity作为库的Xcode项目。
  • 配置Podfile避免重复引入:在主App的Podfile中,让UnityFramework复用主App的Firebase库,不要单独添加依赖:
    target 'MyApp' do
      # 主App的Firebase依赖
      pod 'Firebase/Core'
      # 其他Firebase组件...
    end
    
    target 'UnityFramework' do
      inherit! :search_paths
      # 此处不添加任何Firebase依赖
    end
    
  • 单一Firebase初始化:只在主App的AppDelegate或@main结构体中调用FirebaseApp.configure()一次,注释掉Unity侧的初始化逻辑。
  • 清理构建缓存:删除Xcode的Derived Data,执行pod deintegrate && pod install重新安装依赖,清理主App和UnityFramework的Build文件夹。
  • 处理Swift符号冲突:如果出现Swift类重复定义警告,将主App的Build Settings中Always Embed Swift Standard Libraries设为YES,确保Swift库只被主App嵌入一次。

内容的提问来源于stack exchange,提问作者Luca Rocchi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 14:17:03