Unity3D calling iOS Functions

Hi,
I have 2 questions regarding about calling iOS functions.

  1. How can I call an Obj-C function?
    Right now in my Unity3d C# code, I have:

    [DllImport(“__Internal”)]

     static extern public void _PressButton();
    

I’m calling _PressButton() on my Start() then I export the file as a simulator. And in the AppController.mm, I added the following line of code:
extern “C”{

       void _PressButton(){

            NSLog(@"Hello World");

       }
}

However, it seems to fail…

  1. I wanted to add another view ontop of the project. So, I went to OPENEAGL_UnityCallback(…) and added this line of code ontop of [_windows makeKeyAndVisisble];

    MyView *myView = [[MyView alloc]init];

    [sGLViewController.view addSubview:myView.view];

It somehow pops up an error to me about OBJC_CLASS$_MyView, of the linker command failed with exit code.

Is it because I’m running on a simulator and not an actual device? May anyone give me some tips on how to fix this.

In my experience receiving callbacks from the ObjC layer only works on device, not in the simulator because the ObjC side hasn’t been compiled yet. You can still use XCode’s terminal to see log messages from your actual on-device build though if it’s built in debug mode.