我正在尝试使用此集成指南将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
这是一个cocoapods问题.尝试通过编辑yoga.podspec文件来公开所需的标题:node_modules / react-native / ReactCommon / yoga / yoga.podspec
在yoga.podspec结束时添加这一行:
原文链接:https://www.f2er.com/react/300917.html在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
参考:https://github.com/facebook/react-native/issues/17893
实际拉动请求:https://github.com/facebook/react-native/pull/17764.看看Plo4ox的评论.