Firebase/CrashReporting 中带有调试版本的未定义符号

Undefined symbols with debug builds in Firebase/CrashReporting

自从通过 Cocoapods 更新到 Firebase 崩溃报告 3.8.0 后,我在调试模式的构建过程中看到以下错误。我能够在发布模式下构建而不会出错。

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_GTMLogNoFilter", referenced from:
      objc-class-ref in FirebaseCrash(FCRSystemLogger_6532fb37dc095ffa73463b57baf5fca7.o)
  "_OBJC_CLASS_$_GTMLogBasicFormatter", referenced from:
      objc-class-ref in FirebaseCrash(FCRSystemLogger_6532fb37dc095ffa73463b57baf5fca7.o)
  "_OBJC_CLASS_$_GTMLogger", referenced from:
      objc-class-ref in FirebaseCrash(FCRSystemLogger_6532fb37dc095ffa73463b57baf5fca7.o)
      objc-class-ref in FirebaseCrash(uploader_089041b840f448492d858d7daf481e47.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

当 XCode 设置 Build Active Architecture Only 在调试模式下设置为 NO 时会发生这种情况。

一些 Firebase SDK 依赖 pods 从源代码构建。默认情况下,当 运行 在调试中。这种不匹配会导致您提到的符号丢失。

有两种方法可以解决此问题:

  1. Build Active Architecture Only 切换为 YES 主要项目。
  2. 在调试时将 pods' Build Active Architecture Only 设置为 NO(取自这个 post):

    post_install do |installer_representation|
      installer_representation.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
        end
      end
    end