How do I include a framework in an OS X native bundle?
I am trying to create a wrapper (bundle) for an OS X framework. In Unity, I'm getting the following error:
Couldn't open Assets/Affdex/Plugins/affdex-native.bundle/Contents/MacOS/affdex-native, error: dlopen(Assets/Affdex/Plugins/affdex-native.bundle/Contents/MacOS/affdex-native, 2): Library not loaded: affdex-native.framework/Versions/2.1.0./affdex-native
Referenced from: /Users/foresthandford/git/unity/UnityPlugin/Assets/Affdex/Plugins/affdex-native.bundle/Contents/MacOS/affdex-native
Reason: image not found
From my searches on this forum, "image not found" often means there is either no binary or an inappropriate binary. The bundle has a universal binary:
ForestsMacbook:Plugins foresthandford$ file affdex-native.bundle/Contents/MacOS/affdex-native
affdex-native.bundle/Contents/MacOS/affdex-native: Mach-O universal binary with 2 architectures
affdex-native.bundle/Contents/MacOS/affdex-native (for architecture x86_64): Mach-O 64-bit bundle x86_64
affdex-native.bundle/Contents/MacOS/affdex-native (for architecture i386): Mach-O bundle i386
The versioning from the framework seems, however, to be incorrect:
ForestsMacbook:Plugins foresthandford$ otool -L affdex-native.bundle/Contents/MacOS/affdex-native
affdex-native.bundle/Contents/MacOS/affdex-native:
affdex-native.framework/Versions/2.1.0./affdex-native (compatibility version 0.0.0, current version 0.0.0)
Currently the framework appears as part of the binary within the bundle. I've heard a suggestion that the framework may need to exist as files separate from the binary (ie: not just compiled into the binary).
Is framework inclusion really the issue?
If it is, how do I fix it?
Does someone have an example XCode project I could look at (I found several OS X plugins in GitHub but none included the .xcodeproj file)?
The closest related question I could find was http://answers.unity3d.com/questions/49150/building-osx-bundles-for-unity-extensions-with-ext.html#comment-1122489 , but it doesn't show how the framework was included. This is my first foray into XCode and I might be missing something obvious.
Answer by forestjay · Feb 03, 2016 at 10:24 PM
This has been resolved. I'm not sure ALL the steps I took were needed.
I replaced the framework I was using with a dynamic library. The theory was that because I was using dlopen I should be using a dynamic library.
I put the dynamic library inside the bundle at the same location as the binary (affdex-native.bundle/Contents/MacOS)
I used 'install_name_tool -id @loader_path/libaffdex-native.dylib libaffdex-native.dylib' to change the path to the dynamic library. Note, this was the most obscure change I made and it took all the Google-fu I had to find it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612055230im_/https://answers.unity.com/themes/thub/images/avi.jpg)