3131#import " app_delegate_service.h"
3232
3333#import " godot_view_apple_embedded.h"
34+ #import " godot_view_controller.h"
3435#import " os_apple_embedded.h"
35- #import " view_controller.h"
3636
3737#include " core/config/project_settings.h"
3838#import " drivers/coreaudio/audio_driver_coreaudio.h"
4141#import < AVFoundation/AVFoundation.h>
4242#import < AudioToolbox/AudioServices.h>
4343
44- #define kRenderingFrequency 60
45-
46- extern int gargc;
47- extern char **gargv;
44+ int gargc;
45+ char **gargv;
4846
4947extern int apple_embedded_main (int , char **);
5048extern void apple_embedded_finish ();
@@ -66,18 +64,23 @@ + (GDTViewController *)viewController {
6664 return mainViewController;
6765}
6866
67+ + (void )setViewController : (GDTViewController *)viewController {
68+ mainViewController = viewController;
69+ }
70+
6971- (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
7072 // TODO: might be required to make an early return, so app wouldn't crash because of timeout.
7173 // TODO: logo screen is not displayed while shaders are compiling
7274 // DummyViewController(Splash/LoadingViewController) -> setup -> GodotViewController
7375
74- #if !defined(VISIONOS_ENABLED)
75- // Create a full-screen window
76- CGRect windowBounds = [[UIScreen mainScreen ] bounds ];
77- self.window = [[UIWindow alloc ] initWithFrame: windowBounds];
78- #else
79- self.window = [[UIWindow alloc ] init ];
80- #endif
76+ // Fetch the command-line arguments from NSProcessInfo
77+ NSArray *arguments = [[NSProcessInfo processInfo ] arguments ];
78+ gargc = (int )[arguments count ];
79+ gargv = (char **)malloc (sizeof (char *) * gargc);
80+ for (int i = 0 ; i < gargc; i++) {
81+ NSString *arg = arguments[i];
82+ gargv[i] = strdup ([arg UTF8String ]);
83+ }
8184
8285 int err = apple_embedded_main (gargc, gargv);
8386
@@ -87,23 +90,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
8790 return NO ;
8891 }
8992
90- GDTViewController *viewController = [[GDTViewController alloc ] init ];
91- viewController.godotView .useCADisplayLink = bool (GLOBAL_DEF (" display.iOS/use_cadisplaylink" , true )) ? YES : NO ;
92- viewController.godotView .renderingInterval = 1.0 / kRenderingFrequency ;
93-
94- self.window .rootViewController = viewController;
95-
96- // Show the window
97- [self .window makeKeyAndVisible ];
98-
9993 [[NSNotificationCenter defaultCenter ]
10094 addObserver: self
10195 selector: @selector (onAudioInterruption: )
10296 name: AVAudioSessionInterruptionNotification
10397 object: [AVAudioSession sharedInstance ]];
10498
105- mainViewController = viewController;
106-
10799 int sessionCategorySetting = GLOBAL_GET (" audio/general/ios/session_category" );
108100
109101 // Initialize with default Ambient category.
0 commit comments