SDL2 IOS How to get UIViewController

Hi everyone, I’m making a mobile game with SDL2 to put initially on IOS.

Now, to integrate it with Firebase and other tools, I need a pointer to UIViewController.

After reading countless topics, I tried this:

SDL_SysWMinfo systemWindowInfo;
SDL_VERSION (& systemWindowInfo.version);
SDL_GetWindowWMInfo (sdlWindow, & systemWindowInfo))
UIWindow * appWindow = mainWindowWMInfo.info.uikit.window;
UIViewController * rootViewController = appWindow.rootViewController;

But the line “UIViewController * rootViewController = appWindow.rootViewController;” causes this error: “Incomplete definition of type ‘_UIWindow’”

All topics related to this sample code are at least four years old, and I’m trying hard, but I haven’t found any topics talking recently about how to get UIViewController in an SDL2 / ios project.

So, my questions are:

  1. Is the sample code above still working in the current versions of SDL2 or has something changed in the latest version and this sample code no longer works?
  2. If the sample code still works, what am I doing wrong to cause this “Incomplete definition of type ‘_UIWindow’” error?
  3. If this sample code no longer works in SDL2, how can I get a UIViewController pointer in the current version of SDL2?

Any help is welcome because I have been stuck in this problem for days. I’ve been working on this game for ten months and solving this problem is the last task to complete it, so I really need to solve this issue.

If I’m understanding this right, you’re getting your game running in iOS under SDL but you want to have access to the UIViewController directly for some reason, like injecting a UIKit control as an overlay or something?

If so, take a look at what I did in my Quake 3 port - I subclassed SDL_uikitviewcontroller and went from there

Note that it’s not ideal, there’s some performance hits and the occasional threading issue (the little on-screen joystick in my DOOM 3 port sometimes gets stuck for a few seconds) but that’s one way to do it