問題描述
Pod集成移動監控引入FBRetainCycleDetector,會出現以下問題:
問題一:FBRetainCycleDetector編譯報錯
Cannot initialize a parameter of type 'id<NSCopying> _Nonnull' with an rvalue of type 'Class'
。問題二:應用切換到到后臺就報錯。
解決方案
在Podfile的末尾添加以下內容:
post_install do|installer|
#解決問題一
find_and_replace("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm",
"layoutCache[currentClass] = ivars;", "layoutCache[(id)currentClass] = ivars;")
#解決問題二
find_and_replace("Pods/FBRetainCycleDetector/fishhook/fishhook.c",
"indirect_symbol_bindings[i] = cur->rebindings[j].replacement;", "if (i < (sizeof(indirect_symbol_bindings) /
sizeof(indirect_symbol_bindings[0]))) { \n indirect_symbol_bindings[i]=cur->rebindings[j].replacement; \n }")
end
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
FileUtils.chmod("+w",name) #add
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
系統顯示類似如下。
再重新執行Pod install。
適用于
崩潰分析
性能分析
文檔內容是否對您有幫助?