Can you build iOS plugins using objective-c or only with pure c?

Hey :slight_smile:

I’m in the proces of learning how to build native iOS plugins for Unity. I already have a lot of experience with objective-c as a language, so no problems there.

The problem is that there does not seem to be that much documentation out there on actually building iOS plugins (besides the official documentations which just shows some really shallow pure c functions build into a plugin).

What I am interested in knowing is if it’s possible to build native plugins for iOS using objective-c, or are you forced to using pure C?

For example, could I take this objective-c class and source file:


 @interface TestingThis : NSObject
 -(void) ShowDialog;


@implementation TestingThis

-(void) ShowDialog
    UIAlertView *view = [[UIAlertView alloc] initWithTitle:@"MAO!" message:@"MAO!" delegate:nil cancelButtonTitle:@"OK!" otherButtonTitles:nil];
    [view show];
    [view release];


And use it as a plugin in Unity for displaying a native popup? Or would I have to use pure c functions?

I actually already tried to import the above example source code into my Unity xCode project but unfortunately got linker errors when my test script tried to call the ShowDialog() function.

So can anyone shed some light on this? :slight_smile: Any way to build plugins using pure objective-c?

Well, figured it out in the end. You simply have an objective-c class as my example in the original post. What you do is write a C interface which calls the class methods for you, and then you call the C interface functions through Unity. To the flow is Unity method call → C API → Class method.