Skip to content

Xcode 12.5 compile error: Cannot initialize a parameter of type 'id<NSCopying> _Nonnull' with an rvalue of type  #115

Closed
@imhanhan

Description

@imhanhan

Summary

Getting this error at build time in Xcode 12.5
Cannot initialize a parameter of type 'id _Nonnull' with an rvalue of type '

Code to reproduce

Error on "FBClassStrongLayout.mm" file, line 202
layoutCache[currentClass] = ivars;

iOS version

iOS 14.5

Installation method

pod install

SDK version

FBRetainCycleDetector (0.1.4)

Other information

none

Activity

Q14

Q14 commented on Apr 27, 2021

@Q14
  • 1
    same question
mygithub877

mygithub877 commented on Apr 27, 2021

@mygithub877

same question

SonneFish

SonneFish commented on Apr 27, 2021

@SonneFish

image

Add this post install script to your Podfile:

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

End of the Podfile add this function:

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

facebook/react-native#28405

mygithub877

mygithub877 commented on Apr 27, 2021

@mygithub877

image

Add this post install script to your Podfile:

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

End of the Podfile add this function:

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

facebook/react-native#28405

[!] An error occurred while processing the post-install hook of the Podfile.

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

what to do now?

youngd007

youngd007 commented on Apr 27, 2021

@youngd007
Contributor

Thank you for the report!
layoutCache[(id)currentClass] = ivars;
appears to be the correct fix and it actually appears in the latest code.
https://github.com/facebook/FBRetainCycleDetector/blob/master/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm#L201
Did you perhaps forget to pull?

sapphirezzz

sapphirezzz commented on Apr 28, 2021

@sapphirezzz

Thank you for the report!
layoutCache[(id)currentClass] = ivars;
appears to be the correct fix and it actually appears in the latest code.
https://github.com/facebook/FBRetainCycleDetector/blob/master/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm#L201
Did you perhaps forget to pull?

The latest code has not pushed to CocoaPods . Current version on CocoaPods is 0.1.4 without the fix .

X-man-rascal

X-man-rascal commented on May 2, 2021

@X-man-rascal

image
Add this post install script to your Podfile:

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

End of the Podfile add this function:

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

facebook/react-native#28405

[!] An error occurred while processing the post-install hook of the Podfile.

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

what to do now?

+1

X-man-rascal

X-man-rascal commented on May 2, 2021

@X-man-rascal

@mygithub877 您解决这个问题了吗 我的问题跟你一模一样

laszlotuss

laszlotuss commented on May 3, 2021

@laszlotuss

[!] An error occurred while processing the post-install hook of the Podfile.

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



what to do now?

+1

Pods/FBRetainCycleDetector/FBRetainCycleDetector/Layout/Classes/FBClassStrongLayout.mm

This file is read only, as all Pod source files are. Just add write permissions to yourself on the file.
But at that point if you are the only one working on this project, you can just modify it by hand.

axinger

axinger commented on May 19, 2021

@axinger

sudo chmod -R 750 Pods

aiqinxuancai

aiqinxuancai commented on May 25, 2021

@aiqinxuancai

image
Add this post install script to your Podfile:

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

End of the Podfile add this function:

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

facebook/react-native#28405

[!] An error occurred while processing the post-install hook of the Podfile.

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

what to do now?

Add require:

require "fileutils"

Modify the code:

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
UniqueSilence

UniqueSilence commented on Jun 4, 2021

@UniqueSilence

image
Add this post install script to your Podfile:

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

End of the Podfile add this function:

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

facebook/react-native#28405

[!] An error occurred while processing the post-install hook of the Podfile.

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

what to do now?
******************************_____
execute "pod install" in the terminal window, but report the following errors:

An error occurred while processing the post-install hook of the Podfile.

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

/Users//Podfile:107:in initialize' /Users/***/Podfile:107:in open'
/Users/
/Podfile:107:in block in find_and_replace' /Users/***/Podfile:102:in each'
/Users//Podfile:102:in find_and_replace' /Users/***/Podfile:93:in block (3 levels) in from_ruby'
/Users/
/ruby-2.4.10/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:179:in post_install!' /Users/***/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:897:in run_podfile_post_install_hook'
/Users//.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:885:in block in run_podfile_post_install_hooks' /Users/***/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:145:in message'
/Users/
/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:884:in run_podfile_post_install_hooks' /Users/***/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:329:in block (2 levels) in create_and_save_projects'
/Users//.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in write!' /Users/***/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:328:in block in create_and_save_projects'
/Users/
/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in section' /Users/***/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:307:in create_and_save_projects'
/Users//.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:299:in generate_pods_project' /Users/***/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:178:in integrate'
/Users/
/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:166:in install!' /Users/***/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in run'
/Users//.rvm/gems/ruby-2.4.10/gems/claide-1.0.3/lib/claide/command.rb:334:in run' /Users/***/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in run'
/Users/
/.rvm/gems/ruby-2.4.10/gems/cocoapods-1.10.1/bin/pod:55:in <top (required)>' /Users/***/.rvm/gems/ruby-2.4.10/bin/pod:23:in load'
/Users//.rvm/gems/ruby-2.4.10/bin/pod:23:in <main>' /Users/***/.rvm/gems/ruby-2.4.10/bin/ruby_executable_hooks:22:in eval'
/Users/
/.rvm/gems/ruby-2.4.10/bin/ruby_executable_hooks:22:in `

'

******************************_____

this blocks the executing about checking "Memory-Leaks". but how to solve the issue?

macRong

macRong commented on Jul 21, 2021

@macRong

解决:
layoutCache[(id<NSCopying>)currentClass] = ivars;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @laszlotuss@macRong@aiqinxuancai@X-man-rascal@mygithub877

        Issue actions

          Xcode 12.5 compile error: Cannot initialize a parameter of type 'id<NSCopying> _Nonnull' with an rvalue of type · Issue #115 · facebook/FBRetainCycleDetector