RN 添加 <NavigationContainer>组件报错
RN 添加 <NavigationContainer>组件报错
No component found for view with name "RNCSafeAreaProvider"
这是因为在iOS原生工程中需要pod react-native-safe-area-context 库:
pod 'react-native-safe-area-context', :path => '../node_modules/react-native-safe-area-context'
path路径选择你node_modules放置的路径
添加了上面库后又会报错:
No component found for view with name "RNSScreenContentWrapper"
这是因为缺少RNScreens库
pod 'RNScreens', :path => '../node_modules/react-native-screens'
但是此时又会出现Xcode运行报错
Showing All Errors Only
Undefined symbol: facebook::react::RNSScreenStackEventEmitter::onFinishTransitioning(facebook::react::RNSScreenStackEventEmitter::OnFinishTransitioning) const
.....
多个上述这种错误
改问题是由于采用的是C++ 17或者其他版本的编译器导致Xcode在读取Object-C++时链接不到方法导致的;
解决方案:在pod中添加下面标红这一行即可解决
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => flags[:hermes_enabled],
:new_arch_enabled => false, // 添加这一行
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
即将 new_arch_enabled 设为false,不使用new_arch