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

San*_*ndy 7 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.
Run Code Online (Sandbox Code Playgroud)

我打开了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已经在我的依赖项中。

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

All*_*len 13

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


Flo*_*bre 6

对于最新的RN版本(RN 0.60+),应使用自动链接并仅运行a来修复此类错误pod install

对于旧版本,您应该尝试:

react-native link 在项目的根文件夹中

然后在Xcode Product->Clean Build文件夹中,重新启动JS服务器并尝试重建。

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

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

App.delegate从这里:https : //gist.github.com/brentvatne/1ece8c32a3c5c9d0ac3a470460c65603

资料来源:

Pod安装提醒最早是由Sandy在以下评论中提出的

  • 对于遇到这种情况的任何人,缺少的是运行`pod install` (5认同)