Ios 尝试使用CocoaPods 0.38关闭MagicalRecord loggin时出错

Ios 尝试使用CocoaPods 0.38关闭MagicalRecord loggin时出错,ios,xcode,cocoapods,magicalrecord,Ios,Xcode,Cocoapods,Magicalrecord,我使用ank的解决方案来解决这个问题:在我将CocoaPods更新到最新版本(0.38.2)之前,这个解决方案工作得很好。现在,每当我运行pod install命令时,它都会返回几个错误 以下是ank()共享的原始Podfile片段,仅供参考: 我遇到的第一个问题是,project需要替换为pod文件上的pods\u project,我就是这样做的 但让我陷入困境的是,它无法识别build\u configurations语句,正如您在下面的控制台错误提示中所看到的: ... Generatin

我使用ank的解决方案来解决这个问题:在我将CocoaPods更新到最新版本(0.38.2)之前,这个解决方案工作得很好。现在,每当我运行
pod install
命令时,它都会返回几个错误

以下是ank()共享的原始Podfile片段,仅供参考:

我遇到的第一个问题是,
project
需要替换为pod文件上的
pods\u project
,我就是这样做的

但让我陷入困境的是,它无法识别
build\u configurations
语句,正如您在下面的控制台错误提示中所看到的:

...
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上再次工作,所以我想知道是否有人想出了解决这个问题的方法,或者是否有其他方法关闭MagicalRecord的loggin(顺便说一句,我使用的是版本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

如果您有任何帮助,我们将不胜感激:)

我发现您需要使用
“MagicalRecord”
而不是
“Pods MagicalRecord”
,方法是在安装后添加以下行:

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
#在调试模式下关闭神奇记录日志记录-在发布模式下默认关闭
target=installer.pods_project.targets.find{t|t.to_s==“MagicalRecord”}
target.build|u configurations.each do| config|
s=config.build\u设置['GCC\u预处理器\u定义']
如果s==nil,则s=['$(继承)';
#取消注释一个与您的版本匹配的
#s、 如果config.to_s==“Debug”,则推送('MR_ENABLE_ACTIVE_RECORD_LOGGING=0')MagicalRecord<2.3
#s、 如果config.to_s==“Debug”,则推送('MR_LOGGING_DISABLED=1')MagicalRecord 2.3+
config.build_设置['GCC_预处理器_定义']=s
结束

这一次成功了吗?嗨@Georg抱歉,到目前为止还没有成功。我只是删除了上面的代码,以便完成pod安装命令并生成.xcworkspace文件,但我仍然找不到方法使用CocoaPods 0.38关闭loggin
# 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