Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
182 views
in Technique[技术] by (71.8m points)

ios - Cocoapods: turning MagicalRecord logging off

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.

EDIT: this is not a duplicate as it discusses turning logging off under Cocoapods

question from:https://stackoverflow.com/questions/15284067/cocoapods-turning-magicalrecord-logging-off

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...