Cocoapods: turning MagicalRecord logging off
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 endend
Note that this will only disable logging in the debug configuration - logging is disabled by default in the release configuration.
In my case, I was building a library that depended on MagicalRecord. I didn't want my users to have to add a post_install in their Podfile to silence the noisy logging, so I added it to my podspec instead.
s.prefix_header_contents = '#define MR_ENABLE_ACTIVE_RECORD_LOGGING 0'
This automatically adds this #define
statement to Pods-prefix.pch, which silences MagicalRecord logging in projects that use my pod.
I updated ank's answer for those using the new cocoapods version alongside MagicalRecord 2.3.0:
post_install do |installer| target = installer.pods_project.targets.find{|t| t.to_s == "MagicalRecord"} target.build_configurations.each do |config| s = config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] s = [ '$(inherited)' ] if s == nil; s.push('MR_LOGGING_DISABLED=1') if config.to_s == "Debug"; config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = s endend
Changes:
project
renamed topods_project
- Target
Pods-MagicalRecord
renamed toMagicalRecord
- Macro
MR_ENABLE_ACTIVE_RECORD_LOGGING
renamed toMR_LOGGING_DISABLED
and value changed from0
to1