[英]React Native / iOS SDK. No matching function for call to 'RCTBridgeModuleNameForClass' after update iOS SDK to 14.5
I have updated the iOS SDK platform to version 14.5 .我已将 iOS SDK 平台更新到版本14.5 。 The Xcode version is now 12.5 . Xcode 版本现在是12.5 。 After updating, I cannot launch the application on my device.更新后,我无法在我的设备上启动该应用程序。 And the compiler throws an error:并且编译器会抛出一个错误:
No matching function for call to 'RCTBridgeModuleNameForClass'没有匹配的 function 调用“RCTBridgeModuleNameForClass”
I tried reinstalling the pods but it didn't help.我尝试重新安装 pod,但没有帮助。 How can fix it?如何解决? Thanks谢谢
Put this code at the bottom of your ios/Podfile将此代码放在 ios/Podfile 的底部
post_install do |installer|
## Fix for XCode 12.5
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
end
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
save it, do a pod install
on terminal and try to run/build your project again!保存它,在终端上pod install
并尝试再次运行/构建您的项目!
My post_install function had to be slightly different (using strongModule
instead of module
in the second replace):我的 post_install function 必须略有不同(在第二次替换中使用strongModule
而不是module
):
post_install do |installer|
## Fix for XCode 12.5
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))")
end
I put together all the proposed solutions and got a working version.我把所有建议的解决方案放在一起,得到了一个工作版本。
Podfile播客文件
post_install do |installer|
## Fix for XCode 12.5
find_and_replace("../node_modules/react native/React/CxxBridge/RCTCxxBridge.mm", "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm", "RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))")
end
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 that I got a new error which is related to Flipper:之后我收到了一个与 Flipper 相关的新错误:
Flipper-Folly/folly/synchronization/DistributedMutex-inl.h:1051:5: 'atomic_notify_one<unsigned long>' is unavailable
I used the solution from Xcode throws 'atomic_notify_one' is unavailable to fix this problem.我使用了Xcode throws 'atomic_notify_one' is available的解决方案来解决这个问题。
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# use_flipper!()
And commented out the line # flipper_post_install(installer)
inside post_install do |installer|
并在post_install do |installer|
中注释掉# flipper_post_install(installer)
行。
Last, re-install your pods, rebuil and run your project.最后,重新安装您的 pod,重新构建并运行您的项目。
After updating to Xcode 13.1, I started getting that issue, However, the famous fix that's shared everywhere (RN GitHub issues and here on StackOverflow) didn't work for me but needed a little change!更新到 Xcode 13.1 后,我开始遇到这个问题,但是,到处共享的著名修复程序(RN GitHub 问题和 StackOverflow 上的问题)对我不起作用,但需要一点改变!
RCTBridgeModuleNameForClass(module))
should change to RCTBridgeModuleNameForClass(strongModule))
RCTBridgeModuleNameForClass(module))
应该更改为RCTBridgeModuleNameForClass(strongModule))
and RCTBridgeModuleNameForClass(Class(module)))
to RCTBridgeModuleNameForClass(Class(strongModule)))
和RCTBridgeModuleNameForClass(Class(module)))
到RCTBridgeModuleNameForClass(Class(strongModule)))
As you can see, the given variable name was changed at least in the React Native version I have.如您所见,至少在我拥有的 React Native 版本中,给定的变量名称已更改。
The final code should be looking like this:最终代码应如下所示:
post_install do |installer|
# Fix after updating to Xcode 13.1
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
end
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
This works for me Please Try once if works please.这对我有用,如果有效,请尝试一次。 UPVOTE点赞
Step 1: - Open RCTCxxBridge.mm search this code:第 1 步: - 打开 RCTCxxBridge.mm 搜索此代码:
And change in to this并改成这个
Step 2: - Open RCTTurboModuleManager.mm (line 300) and change RCTBridgeModuleNameForClass(module)) to RCTBridgeModuleNameForClass(Class(module)));第 2 步: - 打开 RCTTurboModuleManager.mm(第 300 行)并将 RCTBridgeModuleNameForClass(module)) 更改为 RCTBridgeModuleNameForClass(Class(module)));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.