1

I am trying to migrate my project to Xcode 12.5 beta but the problem is that build is failing with message cannot initialise a parameter of type 'NSArray<id>' with an rvalue of type 'NSArray'. in RCTCxxBridge.mm file. The same project is working fine on Xcode 11.

PRABHAKAR JHA
  • 11
  • 2
  • 3

1 Answers1

6

This worked for me: https://github.com/facebook/react-native/issues/28405#issuecomment-779382959

--START QUOTE

This was fixed in the new rn version but if you don't want to upgrade

Add this post install script to your Podfile:

post_install do |installer|
    ## Fix for XCode 12.5 beta
    find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
    "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
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

After adding this script, just run pod install command.

Happy Coding ❤️

--END QUOTE

RC Whim
  • 188
  • 3
  • 4