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

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

概述我正在使用这个SO问题的解决方案: Cocoapods: turning MagicalRecord logging off在我将CocoaPods更新到最新版本(0.38.2)之前曾经运作良好.现在每当我运行pod install命令时,它都会返回几个错误. 作为参考,这是ank(link)共享的原始Podfile片段: post_install do |installer| target 我正在使用这个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    endend

我遇到的第一个问题是需要用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    endend

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

解决方法 我发现你需要在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 defaulttarget = 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'] = send
总结

以上是内存溢出为你收集整理的ios – 尝试使用CocoaPods 0.38关闭MagicalRecord登录时出错全部内容,希望文章能够帮你解决ios – 尝试使用CocoaPods 0.38关闭MagicalRecord登录时出错所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1005297.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存