- Home /
objective-c method call from unity
Hi,
I'm trying to call an objective-c method from unity using C#. I'm using the plug-in method described here.
I can get this method to work if I include my header and mm files directly in the Unity generated Xcode project but, what I'm trying to do is create a static library or even a framework with my interface and implementations defined in those but I get an error that my referenced methods are not defined, which happens if I don't even include my .h or .mm files. My problem may be that I'm not creating a framework or a static library correctly (which I suspect is my problem).
Now, my question is: can I even use dllimport in this manner, such as calling a function defined in a static or dynamic xcode library?
Thanks in advance.
Answer by superdev · Jun 12, 2015 at 12:55 AM
@Aram Azhari: I did find a solution to this. Basically what we do now is have an m file or header file as a "bridge" into what we want to call in the static library or framework. So we would do the same dllimport in the CS file, but it calls a method who's signature is unique across the scope of the project and is defined in an mm file located in the Assets->Plugins folder.
thank you. This clarifies a lot of things. I didn't know that we needed a .m uncompiled to access frameworks. This is a start for me, however I still have some issues making the code work. I have asked then in another question.
Your answer
![](https://koobas.hobune.stream/wayback/20220613094613im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Automatically import missing ios frameworks after ios build 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
Google Cardboard problem with Unity 5.6 for iOS when compiling the project on Xcode 2 Answers