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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:46:53  来源:igfitidea点击:

React native base headers for ios not found

iosobjective-cxcodereact-nativelinker

提问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}找不到路径上的标头:

The error

错误

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.his PROJECTROOT/node_modules/react-native/React/Base/RCTLog.h, but the import is #import <React/RCTLog.h>

  • Newly adding React.xcodeprojinto Libraries doesn't help, Xcode's Product > Cleandoesn't help, neither does restarting Xcode

  • react-native run-androidworks, react-native run-iosshows the error

  • File permissions set to the user executing react-native run-ios

  • Link Binary With Libraries 中,我包含了核心 React 库 ( libReact.a)。

  • 的位置RCTLog.hPROJECTROOT/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

Do you have Parallelize buildoption unchecked and React listed first in your build targets?

您是否有Parallelize build未选中的选项并在您的构建目标中首先列出 React?

You can find this window in Xcode => Your project icon near the run button => Edit scheme => Build tab

您可以在 Xcode => 运行按钮附近的项目图标 => 编辑方案 => 构建选项卡中找到此窗口

回答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 只识别配置DebugRelease。React.xcodeproj 的所有输出都写入Debug-iphonesimulatorRelease-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-iphonesimulatorRelease-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.

请单击配置的“+”按钮,然后单击“复制发布配置”,并根据需要对其进行重命名。

enter image description here

在此处输入图片说明

回答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 不兼容。此处显示了修复此问题的构建位置设置:

in XCode->Settings>Locations->Advanced... make sure your Build Location is not set to Legacy, it should be set to Unique

在 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/Publicin 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。问题将得到解决