I’m not able to build a React Native project, which built correctly using Xcode 11, using Xcode 12.5.
I can no longer use Xcode 11 because only more current versions of Xcode carry the necessary API to publish/upload to TestFlight and the app store.
Now I get three build errors:
Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'
Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'
Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'
I also noticed that deployment targets were automatically upgraded from 10 and 9:
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.1;
Some new properties were added related to Clang:
+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
How can I configure the project to deploy this app using Xcode 12.5?
$ react-native info
info Fetching system and libraries information…
System:
OS: macOS 11.3
CPU: (4) x64 Intel(R) Core(TM) i3-8100B CPU @ 3.60GHz
Memory: 256.45 MB / 8.00 GB
Shell: 3.2.57 – /bin/bash
Binaries:
Node: 10.16.0 – /usr/local/bin/node
Yarn: 1.21.1 – ~/npm-global/bin/yarn
npm: 6.9.0 – /usr/local/bin/npm
Watchman: 4.9.0 – /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
IDEs:
Xcode: 12.5/12E262 – /usr/bin/xcodebuild
npmPackages:
react: ^16.11.0 => 16.12.0
react-native: 0.61.4 => 0.61.4
npmGlobalPackages:
react-native-cli: 2.0.1
6
Answers
I fixed this by changing a parameter cast in the React module RCTCxxBridge.mm like so:
To:
I am running 0.59 and not using CocoaPods, but the basic fix is that casts of the form:
Should be replaced with:
This one worked for me.
(NSArray<id<RCTBridgeModule>> *)modules
to(NSArray<Class> *)modules
RCTBridgeModuleNameForClass(module))
toRCTBridgeModuleNameForClass(Class(module)));
This one worked for me. Update the PODFILE with:
And at the end of podfile add a function:
The last step if to run:
i’ve faced the same issue and after using this script the problem was solved for this three error but faced a new one (No matching function for call to ‘RCTBridgeModuleNameForClass’)
which was solved by adding this line in the postinstall script
Fix for XCode 12.5 beta
Open your project in Xcode and go to File > Workspace settings > Build System > Legacy Build System
I had the same problem with Xcode 13.1. But I resolved the problem with this method.