關閉MagicalRecord註銷需要在項目首次包含項目之前創建一個#define,但對於由Cocoapods管理的項目,我無法在其中添加#define豆莢項目。在這種情況下如何完全關閉註銷?Cocoapods:關閉MagicalRecord註銷
花了我幾個小時找出辦法做到這一點,希望它能幫助別人。
編輯:這不是一個重複,因爲它討論的CocoaPods下拐彎註銷
關閉MagicalRecord註銷需要在項目首次包含項目之前創建一個#define,但對於由Cocoapods管理的項目,我無法在其中添加#define豆莢項目。在這種情況下如何完全關閉註銷?Cocoapods:關閉MagicalRecord註銷
花了我幾個小時找出辦法做到這一點,希望它能幫助別人。
編輯:這不是一個重複,因爲它討論的CocoaPods下拐彎註銷
可以使用post_install鉤修改幾乎任何構建設置。就在這個代碼添加到您的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
請注意,這隻會在調試配置禁用日誌 - 日誌默認情況下,在發佈配置中禁用。
+1分享。 – Anupdas 2013-03-08 01:32:51
不用擔心!希望聽到其他解決這個問題的方法。 – 2013-03-08 02:42:18
由於我很少運行'pod update',我只是將它添加到我的pod pch文件中。 – 2013-03-08 13:42:59
就我而言,我建立了一個依賴於MagicalRecord的庫。我不希望我的用戶不得不在他們的Podfile中添加一個post_install來沉默嘈雜的日誌記錄,所以我將它添加到了我的podspec中。
s.prefix_header_contents = '#define MR_ENABLE_ACTIVE_RECORD_LOGGING 0'
這種自動將此#define
聲明豆莢-prefix.pch,這沉默MagicalRecord記錄在使用我的莢項目。
魔法記錄日誌的開發分支(版本2.3.0和更高版本)似乎仍然無法正常工作。當像這樣導入: pod'MagicalRecord',::git =>'https://github.com/magicalpanda/MagicalRecord',:branch =>'develop'
我的Xcode控制檯沒有日誌輸出。但我改變了Cocoapod的post_install腳本。下面應該啓用日誌記錄:與包含在神奇紀錄GCC_PREPROCESSOR_DEFINITIONS記錄可以在2.3.0控制++是buildsetting使用 https://gist.github.com/Blackjacx/e5f3d62d611ce435775e
[MagicalRecord setLoggingLevel:]
可以在波德項目關閉日誌記錄!
只需添加預處理宏:
只要進入 「豆莢」(!!!)項目。
然後找出Pods-MagicalRecord目標。
選擇 「生成設置」 選項卡
查找 「蘋果LLVM 6.1預處理」 - > 「處理器宏」
首次展示 「處理器宏」,並添加到 「調試」 模式:「MR_ENABLE_ACTIVE_RECORD_LOGGING = 0「
這是一切!
只要您運行'pod update',就會停止工作:( – deanWombourne 2015-11-05 16:00:46
我更新ANK的答案使用新的CocoaPods版本一起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
end
end
變化:
project
更名爲pods_project
Pods-MagicalRecord
更名爲MagicalRecord
MR_ENABLE_ACTIVE_RECORD_LOGGING
更名爲MR_LOGGING_DISABLED
和值從0
變爲1
[禁用MagicalRecord錯誤消息和警告]的可能的複製(http://stackoverflow.com/questions/12908584/disable-magicalrecord-error-messages-and-warnings) – 2016-01-26 09:59:40