在xcode12.5.1上FBClassStrongLayout 编译时报错,Cannot initialize a parameter of type 'id _Nonn...

在xcode12.5.1上FBClassStrongLayout 编译时报错

Cannot initialize a parameter of type 'id _Nonnull' with an rvalue of type 'Class'

解决方法(亲测有效):
在podfile文件最后一行加入下面代码,然后在pod install 一下,重新编译即可。

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;")
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

你可能感兴趣的:(在xcode12.5.1上FBClassStrongLayout 编译时报错,Cannot initialize a parameter of type 'id _Nonn...)