Executing native iOS code in Unity

I want to execute following code in Unity.

    UIImage *image      = [UIImage imageNamed:@"roadfire.png"];
    NSString *message   = @"Best image from my application.";
    
    NSArray *postItems  = @[message, image];
    
    UIActivityViewController *activityVc = [[UIActivityViewController alloc]initWithActivityItems:postItems applicationActivities:nil];
    [self presentViewController:activityVc animated:YES completion:nil];

I have implemented similar code for Android using AndroidJavaObject and AndroidJavaClass object but I can’t able to understand how to convert this code?

Only starting point become enough for me.

AndroidJavaObject and AndroidJavaClass are wrapping the JNI interface that is available for native code by the JVM. So your route is:

your managed code -> Unity's native JNI wrapper -> Java

iOS of course doesn’t run Java since iOS requires all code to be compiled AOT to xcode / objective c. When you build an iOS project, Unity just creates an xcode project which then can be built using xcode. You are free to change the code that Unity has cross compiled, however you have to do this every time when you rebuild the xcode project from Unity.

It’s probably possible to compile a native library for iOS that you can add to the Unity project itself as “plugin”. However i’m not familiar with iOS development. Maybe someone else know how to create “objective c plugins” for unity.

I don’t like the objective c syntax. It looks “too alien” to me :smiley: