Cocoapods: turning MagicalRecord logging off

前端 未结 5 1208
傲寒
傲寒 2020-12-23 09:39

Turning MagicalRecord logging off requires a #define to be made before it is first included in the project, but in the case of a project managed by Cocoapods I have no acces

5条回答
  •  情书的邮戳
    2020-12-23 10:29

    You can use a post_install hook to modify pretty much any build setting. Just add this code to your Podfile:

    post_install do |installer|
      target = installer.project.targets.find{|t| t.to_s == "Pods-MagicalRecord"}
        target.build_configurations.each do |config|
            s = config.build_settings['GCC_PREPROCESSOR_DEFINITIONS']
            s = [ '$(inherited)' ] if s == nil;
            s.push('MR_ENABLE_ACTIVE_RECORD_LOGGING=0') if config.to_s == "Debug";
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = s
        end
    end
    

    Note that this will only disable logging in the debug configuration - logging is disabled by default in the release configuration.

提交回复
热议问题