diff --git a/TweakLoader/TweakLoader.m b/TweakLoader/TweakLoader.m index 7adab5b..9c95cfb 100644 --- a/TweakLoader/TweakLoader.m +++ b/TweakLoader/TweakLoader.m @@ -24,14 +24,17 @@ } static void showDlerrAlert(NSString *error) { + UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Failed to load tweaks" message:error preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; + UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + window.windowScene = nil; + }]; [alert addAction:okAction]; UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Copy" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { UIPasteboard.generalPasteboard.string = error; + window.windowScene = nil; }]; [alert addAction:cancelAction]; - UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; window.rootViewController = [UIViewController new]; window.windowLevel = 1000; window.windowScene = (id)UIApplication.sharedApplication.connectedScenes.anyObject; @@ -67,18 +70,20 @@ static void TweakLoaderConstructor() { } // Load selected tweak folder, recursively - NSLog(@"Loading tweaks from the selected folder"); NSString *tweakFolderName = NSBundle.mainBundle.infoDictionary[@"LCTweakFolder"]; - NSString *tweakFolder = [globalTweakFolder stringByAppendingPathComponent:tweakFolderName]; - NSURL *tweakFolderURL = [NSURL fileURLWithPath:tweakFolder]; - NSDirectoryEnumerator *directoryEnumerator = [NSFileManager.defaultManager enumeratorAtURL:tweakFolderURL includingPropertiesForKeys:@[] options:0 errorHandler:^BOOL(NSURL *url, NSError *error) { - NSLog(@"Error while enumerating tweak directory: %@", error); - return YES; - }]; - for (NSURL *fileURL in directoryEnumerator) { - NSString *error = loadTweakAtURL(fileURL); - if (error) { - [errors addObject:error]; + if (tweakFolderName.length > 0) { + NSLog(@"Loading tweaks from the selected folder"); + NSString *tweakFolder = [globalTweakFolder stringByAppendingPathComponent:tweakFolderName]; + NSURL *tweakFolderURL = [NSURL fileURLWithPath:tweakFolder]; + NSDirectoryEnumerator *directoryEnumerator = [NSFileManager.defaultManager enumeratorAtURL:tweakFolderURL includingPropertiesForKeys:@[] options:0 errorHandler:^BOOL(NSURL *url, NSError *error) { + NSLog(@"Error while enumerating tweak directory: %@", error); + return YES; + }]; + for (NSURL *fileURL in directoryEnumerator) { + NSString *error = loadTweakAtURL(fileURL); + if (error) { + [errors addObject:error]; + } } } diff --git a/TweakLoader/UIKit+GuestHooks.m b/TweakLoader/UIKit+GuestHooks.m index fc4bb0b..30ac378 100644 --- a/TweakLoader/UIKit+GuestHooks.m +++ b/TweakLoader/UIKit+GuestHooks.m @@ -16,14 +16,17 @@ void LCShowSwitchAppConfirmation(NSURL *url) { } NSString *message = [NSString stringWithFormat:@"%@\nAre you sure you want to switch app? Doing so will terminate this app.", url]; + UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"LiveContainer" message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { [NSClassFromString(@"LCSharedUtils") launchToGuestAppWithURL:url]; + window.windowScene = nil; }]; [alert addAction:okAction]; - UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; + UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { + window.windowScene = nil; + }]; [alert addAction:cancelAction]; - UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; window.rootViewController = [UIViewController new]; window.windowLevel = UIApplication.sharedApplication.windows.lastObject.windowLevel + 1; window.windowScene = (id)UIApplication.sharedApplication.connectedScenes.anyObject;