I have upgraded my expo and react native and now I am getting “EXDevLauncher/ExpoDevLauncherAppDelegateSubscriber.swift:8: Fatal error: Cannot find the keyWindow. Make sure to call window.makeKeyAndVisible().” while building my app in Xcode. I tried to solve it by somehow changing AppDelegate.m file, but it didn’t worked. Here are the AppDelegate and SceneDelegate files. I found out that they can cause it so I post them there, but if more files are needed let me know:`
#import
#import
#import
@interface AppDelegate : EXAppDelegateWrapper
@end
`
#import "AppDelegate.h"
// @generated begin react-native-maps-import - expo prebuild (DO NOT MODIFY) sync-f2f83125c99c0d74b42a2612947510c4e08c423a
#if __has_include()
#import
#endif
// @generated end react-native-maps-import
#import
#import
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if __has_include()
[GMSServices provideAPIKey:@"AIzaSyCDnK85Y_BEl8g-tdrdSl8eC2VGotnEB5k"];
#endif
self.moduleName = @"main";
self.initialProps = @{};
NSLog(@"[AppDelegate] didFinishLaunching begin");
// Call super but WITHOUT creating a window (SceneDelegate will do that)
BOOL result = [super application:application didFinishLaunchingWithOptions:launchOptions];
NSLog(@"[AppDelegate] didFinishLaunching end");
return result;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
return [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
}
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
@end
#import
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
#import "SceneDelegate.h"
#import
#import
#import
#import "AppDelegate.h"
@implementation SceneDelegate
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
if (![scene isKindOfClass:[UIWindowScene class]]) { return; }
UIWindowScene *windowScene = (UIWindowScene *)scene;
NSLog(@"[SceneDelegate] willConnectToSession");
// Create window for this scene
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
NSLog(@"[SceneDelegate] window created");
// Get AppDelegate for dev launcher delegate
AppDelegate *appDelegate = (AppDelegate *)UIApplication.sharedApplication.delegate;
// Make window visible AFTER dev launcher is initialized
[self.window makeKeyAndVisible];
NSLog(@"[SceneDelegate] window makeKeyAndVisible called");
// NOW start dev launcher with the window
NSLog(@"[SceneDelegate] EXDevLauncherController startWithWindow called");
EXDevLauncherController *controller = [EXDevLauncherController sharedInstance];
[controller startWithWindow:self.window delegate:appDelegate launchOptions:nil];
NSLog(@"[SceneDelegate] setup complete, window is key and visible");
}
- (void)sceneDidDisconnect:(UIScene *)scene {
NSLog(@"[SceneDelegate] sceneDidDisconnect");
}
- (void)sceneDidBecomeActive:(UIScene *)scene {
NSLog(@"[SceneDelegate] sceneDidBecomeActive");
}
- (void)sceneWillResignActive:(UIScene *)scene {
NSLog(@"[SceneDelegate] sceneWillResignActive");
}
- (void)sceneWillEnterForeground:(UIScene *)scene {
NSLog(@"[SceneDelegate] sceneWillEnterForeground");
}
- (void)sceneDidEnterBackground:(UIScene *)scene {
NSLog(@"[SceneDelegate] sceneDidEnterBackground");
}
@end
#import
#import "AppDelegate.h"
#import "SceneDelegate.h"
// This category supplies a UIScene configuration at runtime so the app
// uses SceneDelegate even if Info.plist doesn't declare UIApplicationSceneManifest.
@implementation AppDelegate (SceneConfiguration)
- (UISceneConfiguration *)application:(UIApplication *)application
configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession
options:(UISceneConnectionOptions *)options
{
UISceneConfiguration *config = [UISceneConfiguration configurationWithName:@"Default Configuration"
sessionRole:connectingSceneSession.role];
config.delegateClass = [SceneDelegate class];
return config;
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions
{
// No-op. Implemented to fully adopt UIScene lifecycle.
}
@end