加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – 尝试使用CocoaPods 0.38关闭MagicalRecord登录时出错

发布时间:2020-12-14 17:24:01 所属栏目:百科 来源:网络整理
导读:我正在使用这个SO问题的解决方案: Cocoapods: turning MagicalRecord logging off在我将CocoaPods更新到最新版本(0.38.2)之前曾经运作良好.现在每当我运行pod install命令时,它都会返回几个错误. 作为参考,这是ank(link)共享的原始Podfile片段: post_insta
我正在使用这个SO问题的解决方案: Cocoapods: turning MagicalRecord logging off在我将CocoaPods更新到最新版本(0.38.2)之前曾经运作良好.现在每当我运行pod install命令时,它都会返回几个错误.

作为参考,这是ank(link)共享的原始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

我遇到的第一个问题是需要用Podfile上的pods_project替换项目,所以我做了.

但让我陷入困境的是它无法识别build_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上再次运行,因此我想知道是否有人提出了解决此问题的方法,或者是否有另一种方法可以关闭loggin for MagicalRecord(BTW我使用的是2.2版本).

这是我的Podfile的最后一部分:

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

任何帮助将受到广泛赞赏:)

解决方法

我发现你需要在post_install中添加以下行来使用“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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读