1
votes

I'm trying to add the OPN framework to add support for importing batches from a Opticon hand scanner device. I added the framework to the project

enter image description here

Added it in the copy build phase

enter image description here

And added a run path search path

enter image description here

The full error I got at first is this one:

dyld: Library not loaded: /Users/[original developer of framework]/Development/Mac OPN API/trunk/Sources/opn_api/build/OPN API.build/Release/OPN.build/Objects-normal/i386/OPN
Referenced from: /Volumes/Hard Disk Drive/users/[My name]/Library/Developer/Xcode/DerivedData/barcode-test2-dvksadjkbyeilghbcdcgfqwrvwcb/Build/Products/Debug/barcode-test2.app/Contents/MacOS/barcode-test2
Reason: image not found

I think I'm getting the local path to the developer's hard drive because that might have been left in by accident and is the last path that it tries to resolve before finally failing.

When I check if the framework is copied to the right directory I see that I indeed copy it in the Frameworks folder.

When I use otool to check the paths I don't see the right path anywhere:

My-MacBook:MacOS me$ otool barcode-test2 -L barcode-test2: /Users/[Original developer]/Development/Mac OPN API/trunk/Sources/opn_api/build/OPN API.build/Release/OPN.build/Objects-normal/i386/OPN (compatibility version 0.0.0, current version 0.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 19.0.0) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 945.18.0) /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1187.39.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.19.0)

otool on the OPN binary:

My-MacBook:OPN.framework me$ otool -L OPN OPN (architecture i386): /Users/[Original Developer]/Development/Mac OPN API/trunk/Sources/opn_api/build/OPN API.build/Release/OPN.build/Objects-normal/i386/OPN (compatibility version 0.0.0, current version 0.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 368.35.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 18.0.0) OPN (architecture ppc): /Users/[Original Developer]/Development/Mac OPN API/trunk/Sources/opn_api/build/OPN API.build/Release/OPN.build/Objects-normal/ppc/OPN (compatibility version 0.0.0, current version 0.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 368.35.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 18.0.0)

Shouldn't I see something like @executable_path/../Frameworks/ or a resolved version of that here?

I added the OPN file at the right place where it's searching for it and sure it builds right now, but I really don't like to have a complete extra path through my Users directory just to make this build.

I have tried many variations of install_name_tool but every time I execute the command it doesn't give an error or a confirmation and when I check again with otool -L nothing changed.

2

2 Answers

2
votes

Add @executable_path/../Frameworks into installation Directory of OPN framework build settings.

enter image description here

1
votes

I figured it out in the end and for all who might end up here through Google I'll add the answer as well.


Solution

First I went to the location of the executable itself via Terminal and tried it manually. This is the incantation that finally worked:

install_name_tool -change "/Users/[Original developer]/Development/Mac OPN API/trunk/Sources/opn_api/build/OPN API.build/Release/OPN.build/Objects-normal/i386/OPN" @executable_path/../Frameworks/OPN.Framework/OPN barcode-test2

So the original path you want to change needs to match exactly and you need to match the binary inside the framework not the bundle.

When I got that figured out it was time to automate it this procedure because every time I would build the project it would have the wrong settings again.

enter image description here

In the Build Phases tab I added a Run Script phase by using the + in the top left corner, then I added the following line:

install_name_tool -change "/Users/[Original Developer]/Development/Mac OPN API/trunk/Sources/opn_api/build/OPN API.build/Release/OPN.build/Objects-normal/i386/OPN" @executable_path/../Frameworks/OPN.Framework/OPN "$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH"

Real name changed for [Original developer], so copy pasting blindly obviously won't work ;)