question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build failed after update Xcode 13.2.1 beta Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'

See original GitHub issue

New Version

0.62.2

Old Version

0.62…

Build Target(s)

iOS

Output of react-native info

info Fetching system and libraries information… System: OS: macOS 11.6.2 CPU: (6) x64 Intel® Core™ i5-8500 CPU @ 3.00GHz Memory: 118.82 MB / 64.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.6.0 - /usr/local/bin/node Yarn: Not Found npm: 7.4.0 - /usr/local/bin/npm Watchman: Not Found Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: API Levels: 29, 30 Build Tools: 28.0.3, 29.0.2, 30.0.3 System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.6953283 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: Not Found Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: ~16.11.0 => 16.11.0 react-native: ~0.62.2 => 0.62.2 npmGlobalPackages: react-native: Not Found

Issue and Reproduction Steps

Upgraded to XCODE 13.2.1 from XCODE 12.x; now can not build for iOS.

ERROR


Showing Recent Errors Only
../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> *'

Showing Recent Errors Only
../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'

Showing Recent Errors Only
../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'

I patched the flipper error by commenting out

#add_flipper_pods!

# post_install do |installer|
  #   flipper_post_install(installer)
# end

But the find_and_replace() patch I can find for NSArray that was for 12.5 here is not working for XCODE 13.2.1.

The goal is to get this app to at least build again.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

4reactions
0906014109commented, Jan 21, 2022

react-native: “^0.57.5” macos version:12.1 Xcode:13.2.1 遇到了楼上一样的问题,怎么解决? 截屏2022-01-21 上午10 59 58

2reactions
WNemenchacommented, Jan 28, 2022

I’m having the same exact issue actually, RN 0.61, XCode 13.2.1, OSX 11.6 (Big Sur) and the proposed fix doesn’t work anymore ❌

[...]/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:330:34: error: cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'
  (void)[self _initializeModules:RCTGetModuleClasses() withDispatchGroup:prepareBridge lazilyDiscovered:NO];
[...]/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:775:79: error: cannot initialize a parameter of type 'NSArray<Class> *' with an lvalue of type 'NSArray<id<RCTBridgeModule>> *__strong'
  NSArray<RCTModuleData *> *moduleDataById = [self _registerModulesForClasses:modules lazilyDiscovered:lazilyDiscovered];
[...]/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:826:69: error: cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an lvalue of type 'NSArray<Class> *__strong'
    NSArray<RCTModuleData *> *newModules = [self _initializeModules:modules withDispatchGroup:NULL lazilyDiscovered:YES];

EDIT: After investigation, this worked in my case:

  1. Create a file like fix-ios.sh in your project root with this inside:
#!/bin/sh
DIR="node_modules"

if [ -d "$DIR" ]; then
  echo "fixing react files in ${DIR}..."
else
  echo "missing node_modules folder, are you running this script from the correct path?"
  exit 1
fi

TARGET_FILE="./node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm"
FROM="_initializeModules:(NSArray<id<RCTBridgeModule>>\ \*)modules"
TO="_initializeModules:(NSArray<Class>\ \*)modules"
sed -i -e "s/$FROM/$TO/g" $TARGET_FILE

TARGET_FILE="./node_modules/react-native/ReactCommon/turbomodule/core/platform/iOS/RCTTurboModuleManager.mm"
FROM="RCTBridgeModuleNameForClass(module))"
TO="RCTBridgeModuleNameForClass(Class(module)))"
sed -i -e "s/$FROM/$TO/g" $TARGET_FILE

echo "Yay! RCTCxxBridge.mm and RCTTurboModuleManager.mm should be fixed now."
  1. chmod a+x fix-ios.sh && ./fix-ios.sh
  2. yarn react-native run-ios
Read more comments on GitHub >

github_iconTop Results From Across the Web

Build failed after update Xcode 12.5 beta Cannot initialize a ...
to xcode 12.5 beta and after update i build app iOS but report error ==> Cannot initialize a parameter of type 'NSArray *'...
Read more >
React Native App no longer builds … | Apple Developer Forums
React Native App no longer builds after upgrading to XCode 12.5 ... Cannot initialize a parameter of type 'NSArray<Class> *' with an lvalue...
Read more >
How to migrate to Xcode 12.5 - Stack Overflow
Open RCTCxxBridge.mm (line 770) and change parameter type from: ... Open your project in Xcode and go to File > Workspace settings >...
Read more >
Oh dear! Build errors? - LoopDocs - GitHub Pages
This page contains build error help for people updating their Loop app as well as ... type "I am not using beta versions");...
Read more >
React Native/Ios Sdk. No Matching Function For Call To ...
i updated xcode 11. to xcode 12.5 beta and after update i build app iOS but ... beta Cannot initialize a parameter of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found