Adventures with the Mac plugin system in UE4
As you probably know, Coherent UI supports all the major desktop platforms – Windows, Linux, MacOSX. So, in theory it should be quite easy to port the plugin for the same platforms for UE4. We’ve set a couple of requirements for that task:
- No engine changes (so you can safely update the UE4 code which is updated frequently)
- There should be no additional steps for the user after the plugin installation
When we first started making the plugin for Windows everything went smooth and we expected the same for the other platforms. Then came our MacOSX port and the code itself was very easy to write. Unfortunately, the deployment of the plugin presented some problems :). The first time I tried building our game for the Editor I got this error:
Investigating a bit further, our sample game (which was built as a dynamic library for the Editor, libCoUITestFPS.dylib) failed to load because one of its dependencies failed to load – namely our plugin. Checking the dependencies of the game revealed the problem – the dependency was actually “@loader_path/libCoherentUIPlugin.dylib”. The “@loader_path” means that the plugin should be in the same directory as the library that loads it. Which is not the case.
My next attempt was to just copy the plugin next to the game. Now the error was different – the plugin was loaded twice from a different location! Okay, I’ll just delete the one in “Plugins” then, and I’ll also have to start the Editor manually since if I do that through XCode it will just output the plugin in the “Plugins” directory again and I’ll get the same error.
Instead I got the next, different error:). This one’s on me though – due to our setup we have to add a line in an ini file that enables our plugin.
The ini file is different for Windows and Mac, though, and I forgot to add the Mac one. After doing so, I was finally able to run the Editor and see Coherent UI in all its glory:
I’d also have to mention that since UE4.1 the ini files in the “Saved” folder were ignored and were now loaded from “~/Library/Preferences/Unreal Engine/” instead, which took me some time to figure out when updating the code.
As you can see, the user experience is not the greatest. We contacted Epic and they acknowledged the issue with the plugin deployment and they’re going to fix it (yay!). Unfortunately, the fix is not yet live in the 4.2 release and the first usage is still a hassle.
With the release of Coherent UI 2.0 and our Blueprint scripting support you can now make your UI with no C++ coding, so we decided to release the Mac port anyway, slightly breaking our promise that there are no additional steps after installation. If you’re not constantly rebuilding the C++ code of your game, you’ll only have to do this plugin setup once and then you’re good to go.
So, if you prefer to have MacOSX as your primary dev platform, stay tuned for our next release where you’ll finally find it.
We’ll see what other hidden obstacles we’ll have to tackle with the Linux support next 😉