xcode 未找到用于 ios 的 React 本机基本标头
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42158178/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
React native base headers for ios not found
提问by Peter G.
During the iOS linking phase, I started seeing errors for my React Native project.
在 iOS 链接阶段,我开始看到 React Native 项目的错误。
React Native version: 0.41.2
, 0.40
, 0.39
反应本机版本:0.41.2
, 0.40
,0.39
All worked fine, I edited the Android version, React Native code didn't change, when this kind of linking errors started showing up with headers on /node_modules/react-native/React/Base/{RCTHeaderName.h}
path not being found:
一切正常,我编辑了 Android 版本,React Native 代码没有改变,当这种链接错误开始出现时,/node_modules/react-native/React/Base/{RCTHeaderName.h}
找不到路径上的标头:
In file included from /Users/user/ReactNativeProject/node_modules/react-native-vector-icons/RNVectorIconsManager/RNVectorIconsManager.h:9:
../react-native/React/Base/RCTBridgeModule.h:12:9: fatal error: 'React/RCTDefines.h' file not found
#import <React/RCTDefines.h>
^
In the Link Binary With LibrariesI include the core React library (
libReact.a
).The location of the
RCTLog.h
isPROJECTROOT/node_modules/react-native/React/Base/RCTLog.h
, but the import is#import <React/RCTLog.h>
Newly adding
React.xcodeproj
into Libraries doesn't help, Xcode'sProduct > Clean
doesn't help, neither does restarting Xcodereact-native run-android
works,react-native run-ios
shows the errorFile permissions set to the user executing
react-native run-ios
在Link Binary With Libraries 中,我包含了核心 React 库 (
libReact.a
)。的位置
RCTLog.h
是PROJECTROOT/node_modules/react-native/React/Base/RCTLog.h
,但导入的是#import <React/RCTLog.h>
新添加
React.xcodeproj
到库中没有帮助,XcodeProduct > Clean
没有帮助,重新启动 Xcode 也没有帮助react-native run-android
有效,react-native run-ios
显示错误文件权限设置为用户执行
react-native run-ios
回答by binchik
回答by DàChún
Update: solution on Facebook React-Native https://github.com/facebook/react-native/issues/11813
更新:Facebook React-Native https://github.com/facebook/react-native/issues/11813上的解决方案
============
============
This issue happened to me also. It seems React.xcodeproj only recognise configuration Debugand Release. All of output of React.xcodeproj is written into Debug-iphonesimulatoror Release-iphonesimulator.
这个问题也发生在我身上。似乎 React.xcodeproj 只识别配置Debug和Release。React.xcodeproj 的所有输出都写入Debug-iphonesimulator或Release-iphonesimulator。
That means if you have some configurations other than "Debug/Release", the output will still be written into Debug-iphonesimulatoror Release-iphonesimulator, that is not what we want.
这意味着如果您有除“Debug/Release”之外的一些配置,输出仍将写入Debug-iphonesimulator或Release-iphonesimulator,这不是我们想要的。
So the solution is to add a same configuration in React.xcodeproj to match the one of your own project.
所以解决方案是在 React.xcodeproj 中添加一个相同的配置来匹配你自己的项目。
For example, if you have "Debug/Release/Test/AppStore" 4 configurations in your own project, you have to make sure React.xcodeproj also has the same 4 configurations.
例如,如果您自己的项目中有“Debug/Release/Test/AppStore”4 个配置,那么您必须确保 React.xcodeproj 也有相同的 4 个配置。
please click the "+" button of Configurations, then "Duplicate Release Configuration", and rename it according to you need.
请单击配置的“+”按钮,然后单击“复制发布配置”,并根据需要对其进行重命名。
回答by Tom Lachapelle
It seems like there are a lot of reasons to be getting these 'missing headers' errors and I've tried a lot of things posted on Stack Overflow and nothing would work. Finally I stumbled upon the solution below that did work for me. Posting in case anyone else has the same issue ... its a bit obscure. For me it was caused by a build locations setting in Xcode that is apparently incompatible with vanilla React Native. The build locations setting that fixed this issue is shown here:
似乎有很多原因会导致这些“缺少标题”错误,我已经尝试了在 Stack Overflow 上发布的很多内容,但没有任何效果。最后,我偶然发现了以下对我有用的解决方案。发布以防其他人有同样的问题......它有点晦涩。对我来说,这是由 Xcode 中的构建位置设置引起的,该设置显然与 vanilla React Native 不兼容。此处显示了修复此问题的构建位置设置:
在 XCode->Settings>Locations->Advanced... 确保你的 Build Location 没有设置为 Legacy,它应该设置为 Unique
Note: the vanilla React Native application may have to be reinitialized from scratch with react-native init ... after changing this setting.
注意:更改此设置后,可能必须使用 react-native init 从头开始重新初始化 vanilla React Native 应用程序。
回答by Roshan James
Add path/project folder/ios/Pods/Headers/Public
in your Library's Build Settings
-> Header Search Path
. The issue will get resolved
添加path/project folder/ios/Pods/Headers/Public
库的 Build Settings
-> Header Search Path
。问题将得到解决