我遇到了错误"创建RCTROOTView需要一个moduleName",然后应用卡在了启动页面,谁能帮我?谢谢。
- 步骤**
1.运行"npx react-native init RN0.71.0RC3--版本0.71.0-rc.3"以创建RN项目
1.创建"应用程序委托. swift""桥接标头. h"并删除"应用程序委托. mm""应用程序委托. h""main. m"
- 应用代理. mm**
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"RN0710RC3";
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
- (BOOL)concurrentRootEnabled
{
return true;
}
@end
- 应用代理. swift**
import Foundation
import UIKit
@UIApplicationMain
class AppDelegate: RCTAppDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
CommonTheme.currentTheme.primaryColor = .red;
self.moduleName = "RN0710RC3";
return self.application(application, didFinishLaunchingWithOptions: launchOptions);
}
override func sourceURL(for bridge: RCTBridge!) -> URL! {
#if DEBUG
return RCTBundleURLProvider.sharedSettings()?.jsBundleURL(forBundleRoot: "index", fallbackResource: nil)
#else
return Bundle.main.url(forResource: "main", withExtension: "jsBundle")
#endif
}
func concurrentRootEnabled() -> Bool {
return true;
}
}
- 桥接-集管. h**
#import <RCTAppDelegate.h>
#import <React/RCTBundleURLProvider.h>
1条答案
按热度按时间jq6vz3qz1#
函数
concurrentRootEnabled
是Objective-C接口RCTAppDelegate
所必需的,因此您应该将@objc
放入其中。