Xcode13.0 FBRetainCycleDetector錯誤 Cannot initialize a parameter of type 'id<NSCopying> _Nonnull' ...

參考:https://github.com/facebook/FBRetainCycleDetector/issues/115

網上搜索資料找到解決方案:修改podfile文件為:

#指明依賴庫的來源地址
source 'https://github.com/CocoaPods/Specs.git'

# 說明平臺是ios,版本是10.0
platform :ios, '10.0'

# 忽略引入庫的所有警告(強迫癥者的福音啊)
inhibit_all_warnings!

target 'TestDemo' do
  
  require "fileutils"
  
  
  post_install do |installer|
    ## Fix for XCode 12.5
    find_and_replace("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm",
      "layoutCache[currentClass] = ivars;", "layoutCache[(id<NSCopying>)currentClass] = ivars;")
  end

  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 'LookinServer', :configurations => ['Debug']
  pod 'MLeaksFinder', :configurations => ['Debug']
  
end

修改完后執行pod install,又出現了新的錯誤:

Generating Pods project
Fix: Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm
[!] An error occurred while processing the post-install hook of the Podfile.

Permission denied @ rb_sysopen - Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm

繼續爬樓搜索看看萬能的網友的終極解決方案...功夫不負有心人,網友的力量是強大的

#指明依賴庫的來源地址
source 'https://github.com/CocoaPods/Specs.git'

# 說明平臺是ios,版本是10.0
platform :ios, '10.0'

# 忽略引入庫的所有警告(強迫癥者的福音啊)
inhibit_all_warnings!

target 'TestDemo' do
  
  require "fileutils"
  
  post_install do |installer|
    installer.pods_project.targets.each do | target |
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["SWIFT_VERSION"] = "4.2"
        config.build_settings["VALID_ARCHS"] = "arm64 arm64e x86_64"
        config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = "10.0"
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
    end
    ## Fix for XCode 12.5
    find_and_replace("Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm",
          "layoutCache[currentClass] = ivars;", "layoutCache[(id<NSCopying>)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

  #
  pod 'LookinServer', :configurations => ['Debug']
  pod 'MLeaksFinder', :configurations => ['Debug']
  
end
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容