macOS: Homebrew dylib formula all hit code-sign errors

此生再无相见时 提交于 2020-01-25 08:45:07

问题


On macOS, I used to work with dynamic libraries installed via Homebrew with issues.

But with my latest setup:

  • Mojave 10.14.6
  • Xcode 11.2.1

I start getting code sign problems with the libs that used to work, such as protobuf.

Below is the console output when running a successfully built project:


dyld: Library not loaded: /usr/local/opt/protobuf/lib/libprotobuf.22.dylib
  Referenced from: /path/to/myproj/_build/Debug/mam-host
  Reason: no suitable image found.  Did find:
    /usr/local/opt/protobuf/lib/libprotobuf.22.dylib: code signature in (/usr/local/opt/protobuf/lib/libprotobuf.22.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
    /usr/local/Cellar/protobuf/3.11.1/lib/libprotobuf.22.dylib: code signature in (/usr/local/Cellar/protobuf/3.11.1/lib/libprotobuf.22.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
Program ended with exit code: 9

What should I do?

Should I just

codesign -s "Mac Developer: me" /usr/local/opt/protobuf/lib/libprotobuf.22.dylib

Or do I have to build from source?

P.S. After running codesign command above I got the exact same error.


回答1:


Finally solved it.

You have two options:

  • Option 1 Disable checking on code-signing for libs: Project Settings > Signing & Capabilities > Hardened Runtime > Runtime Exceptions > Diable Library Validation
  • Option 2: Code-sign libs using your code-signing identity, e.g. Apple Development: Your Name (10-char-ID)
    • Remove public signature: codesign --remove-signature /path/to/theirlib.dylib
    • Sign with project signature: codesign -s "Apple Development: Your Name (10-char-ID)" /path/to/theirlib.dylib


来源:https://stackoverflow.com/questions/59214424/macos-homebrew-dylib-formula-all-hit-code-sign-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!