Problem description
Integrating App Monitor with a pod also imports FBRetainCycleDetector, which causes the following issues:
Issue 1: A compilation error occurs for FBRetainCycleDetector:
Cannot initialize a parameter of type 'id<NSCopying> _Nonnull' with an rvalue of type 'Class'.
Issue 2: An error occurs when the application switches to the background.
Solution
Add the following code to the end of your Podfile:
post_install do|installer|
# Resolve Issue 1
find_and_replace("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm",
"layoutCache[currentClass] = ivars;", "layoutCache[(id)currentClass] = ivars;")
# Resolve Issue 2
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))
endThe output is similar to the following.

Run Pod install again.
Applies to
Crash Analytics
App Performance Analytics
该文章对您有帮助吗?