在iOS模拟器中运行React Native应用时找不到UMModuleRegistryAdapter.h

时间:2019-06-25 00:20:37

标签: ios react-native

我有一个简单的React Native应用程序,我一直在Android上进行测试,现在想在iOS上进行测试。它正在使用React Navigation。

我运行了npm run ios,但出现以下错误:

info In file included from 

/Users/rbbit/reactnative/testproj1/ios/testproj1/main.m:10:

/Users/rbbit/reactnative/testproj1/ios/testproj1/AppDelegate.h:9:9: fatal error: 'UMReactNativeAdapter/UMModuleRegistryAdapter.h' file not found

#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

info 1 error generated.

我打开了XCode,但是我基本上得到了相同的消息,没有别的东西可以帮助我调试它。

我确实看到有一个名为react-native-adapter(https://github.com/expo/expo/tree/master/packages/%40unimodules/react-native-adapter)的软件包,但是我很犹豫只安装此软件包,因为我遵循了有关如何包括react-navigation的说明,但没有提到这一点,假设这是相关的。

此外,该页面显示If you are using react-native-unimodules, this package will already be installed and configured!,并且react-native-unimodules已经在我的依赖项中。

关于如何解决这个问题的任何指针?谢谢!

3 个答案:

答案 0 :(得分:12)

pod install对我不起作用,直到我将以下行添加到pod文件中:

require_relative '../node_modules/react-native-unimodules/cocoapods.rb'

use_unimodules!(modules_paths: ['../node_modules'])

然后执行pod install

示例:https://gist.github.com/sjchmiela/6c079f2173938a9a61a7c6f053c45000

答案 1 :(得分:4)

尝试运行 react-native link在您项目的根文件夹中

然后在Xcode Product-> Clean Build文件夹中

重新启动JS服务器并尝试重建。

如果仍然无法正常工作,请从此处再次检查配置:

https://github.com/unimodules/react-native-unimodules

和此处的App.delegatehttps://gist.github.com/brentvatne/1ece8c32a3c5c9d0ac3a470460c65603

答案 2 :(得分:0)

我遇到了完全相同的错误,所有配置正确,其他答案中的所有内容都已完成,所有 unimodules installation steps 已完成,在一个已经工作数月的项目上,在新计算机上构建它。原来是因为我在 xCode 中使用了错误的文件。

我应该打开 .xcodeproj 文件并从 .xcworkspace 文件运行构建。

除了这个错误之外,一切似乎都正常工作,这使它看起来像一个配置问题,而不是一个简单的“你打开了错误的文件”问题。希望如果其他人犯了同样的错误,这将为他们节省几个小时的徒劳修补。