Gaining access to Unity's UIViewController in a native plugin

I have a native plugin, and in one of the functions I call from Unity script I want to get access to the ViewController that Unity is using to display, so I try to call UnityGetGLViewController… but it is not in the scope of my script. It is in AppController.mm, and is not defined in the header file. I am not experienced with objective-c, so I might not be understanding some basics, but how can I give my plugin access to UnityGetGLViewController?

Here is my basic setup:

In testPlugin.h:

#import <Foundation/Foundation.h>

@interface testPlugin : NSObject
{
}

int TestCall();

@end

In testPlugin.m:

#import "testPlugin.h"

@implementation testPlugin

int TestCall()
{

   ....

   UIViewController * unityController = UnityGetGLViewController(); //This doesn't work, the compiler doesn't recognize the function

   ...

}

@end

These files are in the Unity plugins folder under iOS, they appear in the library directory in the generated Xcode project properly, and I have successfully used this plugin setup for other functionalities (such as screen detection and firewall workarounds), so I know this setup works on a basic level…

Any help would be appreciated!

I am now using a workaround if anyone is interested.

I defined a public message in the AppController implementation that returns the UIViewController *, and defined that message in the header file, then included the header file in my plugin.

Hi ztribal
I know this post is old , but I have the same problem as yours, could you publish the code that you use to resolve the problem?