- Home /
How to include dependent dylib for Mac plugin?
The problem is not in the building of my plugin but in allowing Unity to see a 3rd party .dylib.
On Windows I solved this by making sure my code loaded both dll's (using DllImport) and then everything worked fine. I've tried that approach on Mac but that appears not to have worked.
I've read this post and this post to no avail. Possibly because I'm not entirely sure of what I'm doing on a Mac. I'm sure this must have been solved many times over so I'm surprised there isn't clearer docs about this.
Can you help?
Thanks.
I found another post (http://answers.unity3d.com/questions/208625/unity-cannot-find-dependent-dylib-for-plugin.html) that suggested getting the author to change the "Installation Directory" on the 3rd party library, but that's not really an option I can follow.
Answer by HazeTI · Jul 06, 2012 at 08:38 AM
I finally managed to achieve this. This link was extremely useful (as was this). The steps I took were:
Find what the install directory for the 3rd party library is. I used otool for this. Luckily for me the library did use @loader_path.
In your xCode Plugin project, in build phases add the 3rd party .dylib to link binary with libraries.
Add a new "Copy Files" build phase (button bottom right "Add Build Phase").
Depending on what the 3rd party installation directory is set the Destination appropriately. In my case, since it was straight @loader__path I set it to Executable. The other common ones are @executable_path/../Frameworks or @loader_path/../Frameworks, in which case set it to Frameworks.
Add the 3rd party .dylib to the list.
Build!
The .dylib is now included in your bundle and your plugin can call functions from this 3rd party library with no issues. Note that you won't be able to call the 3rd party library functions from Unity, or at least I couldn't figure out how to.
I hope that helps someone, took me days to figure this all out!
Your answer
Follow this Question
Related Questions
What to choose to make .bundle plugin in XCode? 1 Answer
Unity fails to include .bundle for native code plugin when building Intel Mac player. 0 Answers
Why doesn't my bundle build for Mac OS X using Xcode 4.5? 1 Answer
Does Unity 5 support OSX i386 plugins (without x86_64)? 0 Answers
linked dylib in ios project: Unity 5 0 Answers