在Firebase/CrashReporting中使用调试构建的未定义符号

Ian*_*ber 4 ios firebase firebase-crash-reporting

自从通过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)
Run Code Online (Sandbox Code Playgroud)

Kei*_*ons 5

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

一些Firebase SDK依赖于从源构建的pod.默认情况下,的CocoaPods设置构建有源体系只在调试运行时,从源代码构建的所有吊舱.这种不匹配会导致您提到的缺失符号.

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

  1. 切换构建活动体系结构仅在主项目的调试中为YES.
  2. 在调试时(从这篇文章中获取)将您的pod的Build Active Architecture Only设置NO:

    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
    
    Run Code Online (Sandbox Code Playgroud)