microsoft / WinObjC

Objective-C for Windows
MIT License
6.24k stars 809 forks source link

Use WinObjC to create DLL for Unity Windows platform #2861

Open HassanAliCTech opened 6 years ago

HassanAliCTech commented 6 years ago

I have an objective c framework project in Xcode which I use to export .framework to later use in Unity as a Plugin. Is it possible to use that code to generate DLL to use in Unity for Windows.

I have created static library project using vsimporter which generate .lib file but it isnt working in Unity. I am using extern "C" to use that framework in C# and bridge methods are in .mm file.

DHowett-MSFT commented 6 years ago

If Unity applications can be packaged in a UWP, there should be no reason why you cannot use a generate a WinObjC UWP Objective-C DLL and use it. You should be able to switch your static library project to a dynamic library project.

It's mostly dependent on what functionality you're trying to bring over, of course. What are the issues you're seeing? Any project samples, build logs, or runtime exceptions you can share would be helpful.

This isn't explicitly a supported use case, so we can't dedicate terribly much time to looking into issues caused by it, but I'm definitely interested in seeing how you fare.

alakoring commented 6 years ago

It looks like this may be a direction I have to go too — using WinObjC for its Foundation support, but Unity for the majority of my game.

alakoring commented 6 years ago

Any luck? I managed to build a DLL, but I'm not sure how to deploy it (given I want to include resources, and because there are a whole bunch of other DLLs sitting next to it in the “Debug” build folder.

alakoring commented 6 years ago

I’m pretty sure I am blocked by #122. The Unity editor is a 64-bit app, so the plugin has to be 64-bit. (I still have no idea if I would have to copy all the other DLLs, or where to put files for the plugin to read.)

DHowett-MSFT commented 6 years ago

Alas! Even with #122 fixed, you'll have to deploy the subset of WinObjC DLLs you're using along with your plugin. The question of where to put them once you do that is somewhat of a black box to me, as I lack Unity experience.

If there's a 32-bit build of Unity, it might be interesting to play around with that.