命名空间“std”中没有名为“unary_function”的模板;您的意思是“__unary_function”吗?

Mit*_*iya 79 xcode ios react-native xcode15

刚刚将我的 Xcode 升级到 15.0,突然它开始在 RCT_Folly 中出现以下错误

No template named 'unary_function' in namespace 'std'; did you mean '__unary_function'?

这是失败的地方:

结构 hash_base : std::unary_function<T, std::size_t> {};

我尝试删除缓存数据和派生数据并清理构建。也尝试删除 pod 和 node_modules。但没有任何帮助。

小智 114

在此输入图像描述

就我而言,我在构建失败后遵循了 Xcode 的建议。我只需单击“修复”,现在一切正常。

我希望它能在接下来的更新中得到修复。


Gre*_*een 41

运行后我在终端中收到此错误npx react-native run-ios。我通过以下步骤解决了它:

  1. 打开Xcode
  2. 单击播放图标启动模拟器
  3. 模拟器将失败,但 Xcode 会在侧边栏中显示错误。单击错误可以查看代码中的错误位置。
  4. 单击“修复”按钮
  5. 完毕!现在模拟器就可以成功运行了。

在此输入图像描述


小智 39

在源文件中修复此问题之前,最好的选择是在 podfile 中添加已删除的 libcpp 函数,如此处解决的https://github.com/facebook/react-native/issues/37748#issuecomment-1580589448

  post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
        end
      end
  end
Run Code Online (Sandbox Code Playgroud)


Mit*_*iya 16

这有点愚蠢,但我按照__unary_functionXCode 的建议解决了这个问题。

所以实际的线路是..

结构 hash_base : std::__unary_function<T, std::size_t> {};

  • 是的,我现在也得到了这个 - 这个“修复”有效,我想知道它是否会被纳入 RN 的官方内容中...... (2认同)
  • 同意@MattRoberts,每次 Xcode 更新时我们都会不断收到新的愚蠢错误。 (2认同)

tet*_*tar 11

所有库必须更新其代码以使用 std::function 和 std::bind 而不是 unary_function

解决方法

选择 Pods > Build Settings > 在 Apple Clang - Preprocessing 部分 > 在 Macro 部分下

预览添加行

添加发布和调试 -> _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION

ps:要添加此内容,只需单击该列,然后单击底部的“+”->然后粘贴:_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION 预览添加行