【问题标题】:React native 0.61.5 Build is failing on Xcode 12.5 betaReact native 0.61.5 Build 在 Xcode 12.5 beta 上失败
【发布时间】:2021-02-14 10:25:36
【问题描述】:

我正在尝试将我的项目迁移到 Xcode 12.5 测试版,但问题是构建失败并显示消息无法初始化类型为“NSArray”且右值类型为“NSArray”的参数'。在 RCTCxxBridge.mm 文件中。 同一个项目在 Xcode 11 上运行良好。

【问题讨论】:

  • 我遇到了同样的问题。

标签: react-native xcode12 xcode12beta5


【解决方案1】:

这对我有用: https://github.com/facebook/react-native/issues/28405#issuecomment-779382959

--开始报价

这已在新的 rn 版本中修复,但如果您不想升级

将此安装后脚本添加到您的 Podfile:

post_install do |installer|
    ## Fix for XCode 12.5 beta
    find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
    "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
end

Podfile 末尾添加这个函数:

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

添加此脚本后,只需运行 pod install 命令即可。

快乐编码❤️

--结束报价

【讨论】:

    猜你喜欢
    • 2021-07-25
    • 1970-01-01
    • 1970-01-01
    • 2023-01-20
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    • 2021-10-08
    • 2019-12-13
    相关资源
    最近更新 更多