React Native iOS:无法构建模块'yoga':'algorithm'文件未找到

mak*_*tar 9 ios react-native react-native-ios

我正在尝试使用此集成指南将React Native集成到现有的Swift iOS应用程序中:https://facebook.github.io/react-native/docs/integration-with-existing-apps.html.React Native的版本是0.53.0.

我已经成功安装了所有必需的pod,现在尝试构建项目,但总是得到以下编译错误:

在此输入图像描述 在此输入图像描述

在此输入图像描述

错误日志:

While building module 'yoga' imported from ...node_modules/react-native/React/Base/RCTConvert.h:19:
In file included from <module-includes>:1:
In file included from ...ios/Vandebron/Pods/Target Support Files/yoga/yoga-umbrella.h:15:
In file included from ...node_modules/react-native/ReactCommon/yoga/yoga/YGNode.h:13:
...node_modules/react-native/ReactCommon/yoga/yoga/Yoga-internal.h:11:10: fatal error: 'algorithm' file not found
#include <algorithm>
         ^~~~~~~~~~~
1 error generated.
In file included from ...node_modules/react-native/React/Views/RCTActivityIndicatorViewManager.m:10:
In file included from ...node_modules/react-native/React/Views/RCTActivityIndicatorViewManager.h:10:
In file included from ...node_modules/react-native/React/Views/RCTViewManager.h:13:
...node_modules/react-native/React/Base/RCTConvert.h:19:9: fatal error: could not build module 'yoga'
#import <yoga/Yoga.h
Run Code Online (Sandbox Code Playgroud)

小智 10

这是一个cocoapods问题.尝试通过编辑yoga.podspec文件来公开所需的标题:node_modules/react-native/ReactCommon/yoga/yoga.podspec在yoga.podspec结束时添加此行:

spec.public_header_files ='yoga/Yoga.h','yoga/YGEnums.h',

看起来像这样:

      source_files = 'yoga/**/*.{cpp,h}'
       source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION']       
       spec.source_files = source_files    spec.source_files = source_files
+
+  # Only expose the needed headers
+  spec.public_header_files = 'yoga/Yoga.h', 'yoga/YGEnums.h', 'yoga/YGMacros.h'
+
end 
Run Code Online (Sandbox Code Playgroud)

参考:https://github.com/facebook/react-native/issues/17893

实际的拉取请求:https://github.com/facebook/react-native/pull/17764.看看评论Plo4ox.