iOS 查漏报错 模拟器崩溃indirect_symbol_bindings[i] = cur->rebinding FBRetainCycleDetector iOS15 fishhook c...

pod 'MLeaksFinder', :configurations => ['Debug']
  post_install do |installer|
      ## Fix for XCode 12.5
      find_and_replace("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm",
        "layoutCache[currentClass] = ivars;", "layoutCache[(id)currentClass] = ivars;")
      ## Fix for XCode 13.0
        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

push end of the file:

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      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 遇到终端报错:
[!] An error occurred while processing the post-install hook of the Podfile.
Permission denied @ rb_sysopen - Pods/FBRetainCycleDetector/fishhook/fishhook.c

  1. 可以先不添加def find_and_replace(dir, findstr, replacestr)的替换,手动去 Pods/FBRetainCycleDetector/fishhook/fishhook.c文件中替换内容indirect_symbol_bindings[i] = cur->rebindings[j].replacement;if (i < (sizeof(indirect_symbol_bindings) / sizeof(indirect_symbol_bindings[0]))) { indirect_symbol_bindings[i]=cur->rebindings[j].replacement; }
  2. 也可以在Pods/FBRetainCycleDetector/fishhook/fishhook.c文件中随意修改点内容获取修改pods文件的权限。 然后添加上def find_and_replace(dir, findstr, replacestr)的替换 再去pod install

JCLeaksFinder 查漏方式: https://github.com/JerryChu/JCLeaksFinder

pod 'FBRetainCycleDetector', :configurations => ['Debug']
pod 'JCLeaksFinder', :configurations => ['Debug']

MLeaksFinder查漏方式:

pod 'FBRetainCycleDetector', :configurations => ['Debug']
pod 'MLeaksFinder', :configurations => ['Debug']
不报错的库

pod 'MLeaksFinder', :git => "https://github.com/Tencent/MLeaksFinder.git"

你可能感兴趣的:(iOS 查漏报错 模拟器崩溃indirect_symbol_bindings[i] = cur->rebinding FBRetainCycleDetector iOS15 fishhook c...)