iosmacoscodesign

How can I adhoc-sign a library?


Trying to run an executable linking to a dynamic library, I get the following error:

Library not loaded:
[...]
Reason: tried:
    <lib> not valid for use in process: mapped file has no 
    cdhash, completely unsigned? Code has to be at least ad-hoc signed.

How can I ad-hoc sign my lib?


Solution

  • First, you can confirm that your library is not signed with:

    % codesign -d -v <lib>
    

    Which should say:

    <lib>: code object is not signed at all
    

    Ad-hoc sign it with:

    % codesign -s - <lib>