Reputation: 31
I encountered the error "A moduleName is required to create an RCTROotView", and then the app was stuck on the startup page. Who can help me? thank you.
Step
AppDelegate.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
AppDelegate.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;
}
}
Bridging-Header.h
#import <RCTAppDelegate.h>
#import <React/RCTBundleURLProvider.h>
Upvotes: 3
Views: 4884
Reputation: 3812
AppDelegate.swift
import Foundation
import UIKit
@UIApplicationMain
class AppDelegate: RCTAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
self.moduleName = "ModuleName"
self.initialProps = [:]
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func bundleURL() -> URL? {
#if DEBUG
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackExtension: nil)
#else
return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
}
Upvotes: 0
Reputation: 121
return [super application:application didFinishLaunchingWithOptions:launchOptions];
should convert into
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
and then the issue should be solved.
Upvotes: 0
Reputation: 1
The function concurrentRootEnabled
is required by the Objective-C interface RCTAppDelegate
, so you should put @objc
to it.
@objc func concurrentRootEnabled() -> Bool {
return true;
}
Upvotes: 0