[SOLVED]Need help using a C++ bundle plugin in Unity3D using Xcode

I am currently trying to use OpenEXR in a Unity3D project.

I compiled all I needed to get the Xcode Project running, which builds great. Using this Unity Documentation I figured out I had to make a bundle. All the kind of builds you can make in Xcode are explained here.

I made a .cpp interface that included the compiled OpenExr libs and builded it as a bundle. Using the documentation I was able to get my unity project to use my bundle and run perfectly!

Now here is my problem : I submitted all of this (including the .bundle file) on my git and when I pulled on another machine, I got a Dll not found exception when I ran the unity project. As you can read here, bundles are described as : " executable files that your program can load at runtime using dynamic linking functions". Now my understanding of static vs linked libraries might be a bit lagging behind but is it possible that the problem simply comes from the fact that I built my bundle dynamically and that my new machine does not have the compiled binaries (in it’s usr/local folders) ?
I tried to change my Mach-O type from bundle to a static archive library in Xcode (another Mach-O type). Xcode managed to compile and build successfully, but the new “static archive library bundle” did not work in Unity, at least not with my current .cpp interface and .cs Unity interface.

  • Are there other things I would need
    to set in Xcode for it to work or do
    static archive library bundles simply
    not work in unity ?
  • Is there another way to compile
    everything I need statically ? Having
    a big bundle file (~below 50MBs) is
    not a problem for me.
  • If I must work with dynamic bundles,
    is there a way to package all the
    necessary compiled files (.a files in
    my case) inside my project no future
    teammates can easily checkout/pull
    the project without having to compile
    OpenEXR on their own ?

Thank you very much for your help !

Thanks to Dmitry Pyalov I was able to better understand my problem and narrow my research, which led me to this blog post that solved my problem.


Did you check the dependencies of your bundle with “otool”?
Something like:

otool -L MyBundle.bundle/Contents/MacOS/MyBundle

Which should return something like:

	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 55471.0.0)
	@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmono.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1056.0.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1265.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.11.0)

If there are any of the dylibs which may not be present on the user machine, then you should bundle them with your app.
Also, if those names are absolute (not starting with @executable_path), then you should also patch them with “install_name_tool”. Try google on it :slight_smile: Note, that @executable_path refers to your app binary path, not your bundle binary path.

You can automatically bundle the required dylibs with PostProcessPlayer shell script. Check Unity documentation on it.