我正在尝试使用此集成指南将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
2 回答
您可以将以下代码段放入Podfile中以修复此问题以及React Native Cocoapods的其他一些已知问题 . 我们在自己的项目中对它进行了测试,结果非常好:
源代码取自这个要点:https://gist.github.com/Jpunt/3fe75effd54a702034b75ff697e47578
这是一个cocoapods问题 . 尝试通过编辑yoga.podspec文件来公开所需的 Headers :node_modules / react-native / ReactCommon / yoga / yoga.podspec在yoga.podspec结束时添加此行:
spec.public_header_files ='yoga / Yoga.h','yoga / YGEnums.h',
看起来像这样:
参考:https://github.com/facebook/react-native/issues/17893
实际拉取请求:https://github.com/facebook/react-native/pull/17764 . 请查看
Plo4ox
的评论 .