【问题标题】:getting equireNativeComponent: "RNSScreen" was not found in the UIManager IOS获取 equireNativeComponent:在 UIManager IOS 中找不到“RNSScreen”
【发布时间】:2021-12-29 14:30:14
【问题描述】:

我正在尝试从https://reactnavigation.org/docs/tab-based-navigation 运行示例代码

import * as React from 'react';
import {Text, View} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';

function HomeScreen() {
  return (
    <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      <Text>Home!</Text>
    </View>
  );
}

function SettingsScreen() {
  return (
    <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      <Text>Settings!</Text>
    </View>
  );
}

const Tab = createBottomTabNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Tab.Navigator>
        <Tab.Screen name="Home" component={HomeScreen} />
        <Tab.Screen name="Settings" component={SettingsScreen} />
      </Tab.Navigator>
    </NavigationContainer>
  );
}

但是当我在 IOS 模拟器中运行代码时,我得到 UIManager 错误中未找到“RNSScreen”。

我尝试了什么:

  1. 安装以下软件包
npm install @react-navigation/native
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

安装 pod

cd ios
pod install

豆荚似乎正确地进行了链接

为目标 AwesomeProject 自动链接 React Native 模块:RNCMaskedView、RNGestureHandler、RNReanimated、RNScreens、RNVectorIcons、ReactNativeNavigation 和 react-native-safe-area-context

然后我重新启动模拟器并运行

npm start ios

但我不断收到同样的错误。如果你们有任何建议,我有点绝望,我非常欢迎测试它们。

这是我的 package.json

{
  "name": "awesomeproject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/drawer": "^6.1.8",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/stack": "^6.0.11",
    "pod-install": "^0.1.30",
    "react": "17.0.2",
    "react-native": "0.66.4",
    "react-native-elements": "^3.4.2",
    "react-native-gesture-handler": "^2.1.0",
    "react-native-navigation": "^7.24.3",
    "react-native-reanimated": "^2.3.1",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-screens": "^3.10.1",
    "react-native-vector-icons": "^9.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2"
  },
  "jest": {
    "preset": "react-native"
  }
}

谢谢

【问题讨论】:

    标签: ios react-native react-native-navigation


    【解决方案1】:

    发现问题,您需要在 xcode 中运行一次代码以链接库,完成后您可以像往常一样从 npm run 运行。

    【讨论】:

      猜你喜欢
      • 2021-12-28
      • 2021-06-29
      • 2022-10-20
      • 2021-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多