Cocoapods:关闭MagicalRecord [英] Cocoapods: turning MagicalRecord logging off
问题描述
关闭MagicalRecord日志记录需要在项目首次包含之前进行#define,但是对于由Cocoapods管理的项目,我无权在Pods项目中添加#define。在这种情况下如何完全关闭注销?
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 access to add a #define in the Pods project. How do I turn logging off completely in this scenario?
花了几个小时找出方法,在这里发帖,希望它能帮助别人。
Took me a few hours to figure out a way to do it, posting here in the hope it will help others.
编辑:这不是重复,因为它讨论了在Cocoapods
this is not a duplicate as it discusses turning logging off under Cocoapods
推荐答案
您可以使用post_install挂钩修改几乎任何构建设置。只需将此代码添加到您的Podfile:
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.
这篇关于Cocoapods:关闭MagicalRecord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!