react native splash screen get 'React/RCTBridgeModule.h' file not found

允我心安 提交于 2021-01-29 19:32:19

问题


I started a new react native application using :

react-native init myApplication

I started with splash screen so i used this library react native spalsh screen

I linked the library to generate native code using this command :

react-native link react-native-splash-screen

And i added files using Xcode like this :

  1. In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
  2. Go to node_modules ➜ react-native-splash-screen and add SplashScreen.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libSplashScreen.a to your project's Build Phases ➜ Link Binary With Libraries
  4. To fix 'RNSplashScreen.h' file not found, you have to select your project → Build Settings → Search Paths → Header Search Paths to add: $(SRCROOT)/../node_modules/react-native-splash-screen/ios

I build the app using Xcode in a real Iphone and i get this error in RNSplashScreen.h :

    /**
 * SplashScreen
 * 启动屏
 * from:http://www.devio.org
 * Author:CrazyCodeBoy
 * GitHub:https://github.com/crazycodeboy
 * Email:crazycodeboy@gmail.com
 */
#import <React/RCTBridgeModule.h> // <------'React/RCTBridgeModule.h' file not found
#import <UIKit/UIKit.h>

@interface RNSplashScreen : NSObject<RCTBridgeModule>
+ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView;
+ (void)show;
+ (void)hide;
@end

'React/RCTBridgeModule.h' file not found

the Podfile :

    pod 'React', :path => '../node_modules/react-native/'
    pod 'React-Core', :path => '../node_modules/react-native/React'
    ...... # other libaries
    pod 'react-native-splash-screen', :path => '../node_modules/react- 
    native-splash-screen'

AppDelegate.m :

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNSplashScreen.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ....  <------- other code
  [RNSplashScreen show];
  return YES;
}

回答1:


Instead of

#import <React/RCTBridgeModule.h>

use

#import "RCTBridgeModule.h"

Hope this helps you. Feel free for doubts.



来源:https://stackoverflow.com/questions/60165161/react-native-splash-screen-get-react-rctbridgemodule-h-file-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!