Elia Crocetta
Elia Crocetta

Reputation: 368

Exporting functions from Unity to Xcode

So, I have this real simple Unity and Vuforia project, in which I have to use some custom functions that allows me to interact with the iOS project. But when I do Build (from Unity, File -> Build Settings -> iOS -> Build) and after then open my exported Xcode project, I get some errors which refers exactly to my two methods I've made.

This below is one of my custom class with the custom func. I want that when the button in the unity project is being clicked, the iOS project gets a feedback of this event.

enter image description here

This one is the other guilty method

enter image description here

And finally this are the errors I get in Xcode. enter image description here

I have to say that I'm an iOS developer, I never used Unity before. Am I wrong in something?

Unity version: 2019.3.7f1 Vuforia version: 8.5.9

Upvotes: 0

Views: 373

Answers (1)

Julien S.
Julien S.

Reputation: 254

do you have those methods declared in a corresponding .m or .mm file? And is that file included in your Unity project?

If you're not doing so already, you should create a customplugin.mm file and include it in your unity project in a folder called Plugins. And then you can declare your functions in the file like below:

extern "C"{
    void onARButtonClick(const char *message){
        do something here
    }
    void _RecognizedVideo(const char *message){
        do something here
    }
}

I'm not sure what your setup is like so let me know if you're already doing that.

edit: I said Xcode project instead of Unity project. You should include the file in the Unity project in a folder called Plugins so that it is included in the build.

Upvotes: 1

Related Questions