RN运行iOS编译报错,安卓正常

ReactNative

RN报错Cannot initialize a parameter of type 'NSArray> *' with an lvalue of type 'NSArray *__strong'

网上有解决方式:在podfile里面最最下面加上下代码,再pod install:

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

大部分时间好用的。最近,2022年11月初,偶尔不好用了,继续这样报错。

解决:

把AppleDelegate.m文件改为AppleDelegate.mm,加个m,编译C++。即可。

你可能感兴趣的:(ReactNative,react,native,xcode)