Search code examples
code-signingdylibobjective-c-runtimeinstall-name-tool

Mac dylib and executable problem, help needed


So I have to use an old app on a new Mac. The app requires a dylib called libxls.3.dylib to run. However the new Mac did not installed this library and it seems that there's no way to install it at the moment. So I had to find a way to make this work. I tried install_name_tool to modify the load entry of the executable but it gives me a warning saying changes being made to the file will invalidate the code signature in: xteewee.00 and failed. So what am I gonna to do make this old app run? Below is the executable's load entry by otool: Load command 15 cmd LC_LOAD_DYLIB cmdsize 56 name /usr/local/lib/libxls.3.dylib (offset 24)

my install_name_tool command line was as follows,

install_name_tool -change /usr/local/lib/libxls.3.dylib @executable_path/../Frameworks/libxls.3.dylib xteewee.00

Also I've tried many times to copy libxls.3.dylib into /usr/local/lib, but all failed. including sudo cp Apple has blocked every way of making my life easier. Any help will do! Many thanks!


Solution

  • The proper fix is to re-sign the app.

    codesign -s - -f /Applications/Your.app
    

    -s - is for no identity (ad-hoc signature). -f is to replace the existing signature. You'll want to pass the path to the .app folder and not an individual binary here, so that the entire bundle gets signed, with matching Info.plist, etc.

    If the app in question is quarantined (downloaded from the internet), replacing the code signature may trip up Gatekeeper. In that case, also run:

    xattr -rc /Applications/Your.app
    

    Note that if you wish to distribute this to others, then they either need to manually clear the quarantine flag as well, or you need a paid developer account and go through the process of notarisation.