Table of contents

Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type

React Native Nov 15, 2021 Viewed 39 Comments 0

Issue

I upgraded my Mac to macOS Big Sur 11.6 and Xcode to 13.0. When I opened the React Native project in Xcode, an error occurred:

/Volumes/develop//node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:331:34: Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'

/Volumes/develop//node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:776:79: Cannot initialize a parameter of type 'NSArray<Class> *' with an lvalue of type 'NSArray<id<RCTBridgeModule>> *__strong'

/Volumes/develop//node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:827:69: Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an lvalue of type 'NSArray<Class> *__strong'

/Volumes/develop//node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:331:34: Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'

/Volumes/develop//node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:776:79: Cannot initialize a parameter of type 'NSArray<Class> *' with an lvalue of type 'NSArray<id<RCTBridgeModule>> *__strong'

/Volumes/develop//node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:827:69: Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an lvalue of type 'NSArray<Class> *__strong'

package.js:

react: 16.11.0
react-native: 0.62.2

Solution

Fixed by changing a parameter cast like so:

1. node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm

diff --git a/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm b/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm
index 18b0e09..6e676f9 100644
--- a/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm
+++ b/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm
@@ -768,7 +768,7 @@ - (void)registerExtraLazyModules
 #endif
 }
 
-- (NSArray *)_initializeModules:(NSArray *)modules
+- (NSArray *)_initializeModules:(NSArray *)modules
                                withDispatchGroup:(dispatch_group_t)dispatchGroup
                                 lazilyDiscovered:(BOOL)lazilyDiscovered
 {

2. node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm

diff --git a/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm b/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm
index 841f925..24f85ef 100644
--- a/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm
+++ b/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm
@@ -304,7 +304,7 @@ - (void)notifyAboutTurboModuleSetup:(const char *)name
             @"%@ has no setter or ivar for its bridge, which is not "
              "permitted. You must either @synthesize the bridge property, "
              "or provide your own setter method.",
-            RCTBridgeModuleNameForClass(strongModule));
+            RCTBridgeModuleNameForClass((Class)strongModule));
       }
     }
Updated Nov 15, 2021