Error trying to disable MagicalRecord using CocoaPods 0.38

I am using the ank solution from this SO question: Cocoapods: disabling MagicalRecord , which used to work well before I upgraded CocoaPods to the latest version (0.38. 2). Now when I run the command pod install, it returns a few errors.

For reference, here is the original Podfile snippet shared by ank ( link ):

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

The first problem I encountered was that I projecthad to replace it with pods_projecta subfile, which is why I did it.

But the one that made me stuck in the fact that it does not recognize the operator build_configurations, as you can see on the console error below:

...
Generating Pods project
[!] An error occurred while processing the post-install hook of the Podfile.

undefined method `build_configurations' for nil:NilClass
...

, SO, gitHub, . , , , CocoaPods, , - loggin MagicalRecord (BTW 2.2).

:

post_install do |installer|
    target = installer.pods_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

:)

+4
1

, "MagicalRecord" "Pods-MagicalRecord", post_install:

puts installer.pods_project.targets

:

# Turn off Magical Record logging in debug mode - in release mode it is off by default
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;
  # Uncomment one matching your version
  #s.push('MR_ENABLE_ACTIVE_RECORD_LOGGING=0') if config.to_s == "Debug"; # MagicalRecord < 2.3
  #s.push('MR_LOGGING_DISABLED=1') if config.to_s == "Debug"; # MagicalRecord 2.3+
  config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = s
end
+1

Source: https://habr.com/ru/post/1606889/


All Articles