macOS:Homebrew dylib 公式全部命中代码签名错误
macOS: Homebrew dylib formula all hit code-sign errors
在 macOS 上,我曾经使用通过 Homebrew 安装的动态库时遇到问题。
但使用我的最新设置:
- 莫哈韦沙漠 10.14.6
- Xcode 11.2.1
我开始遇到过去工作的库的代码签名问题,例如 protobuf。
以下是 运行 成功构建项目时的控制台输出:
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
我该怎么办?
我应该
codesign -s "Mac Developer: me" /usr/local/opt/protobuf/lib/libprotobuf.22.dylib
还是我必须从源代码构建?
P.S。在上面的 运行 codesign 命令之后,我得到了完全相同的错误。
终于解决了
您有两个选择:
- 选项 1 禁用检查库的代码签名:
Project Settings > Signing & Capabilities > Hardened Runtime > Runtime Exceptions > Diable Library Validation
- 选项 2:使用您的代码签名身份对库进行代码签名,例如
Apple Development: Your Name (10-char-ID)
- 删除public签名:
codesign --remove-signature /path/to/theirlib.dylib
- 用项目签名签名:
codesign -s "Apple Development: Your Name (10-char-ID)" /path/to/theirlib.dylib
在 macOS 上,我曾经使用通过 Homebrew 安装的动态库时遇到问题。
但使用我的最新设置:
- 莫哈韦沙漠 10.14.6
- Xcode 11.2.1
我开始遇到过去工作的库的代码签名问题,例如 protobuf。
以下是 运行 成功构建项目时的控制台输出:
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
我该怎么办?
我应该
codesign -s "Mac Developer: me" /usr/local/opt/protobuf/lib/libprotobuf.22.dylib
还是我必须从源代码构建?
P.S。在上面的 运行 codesign 命令之后,我得到了完全相同的错误。
终于解决了
您有两个选择:
- 选项 1 禁用检查库的代码签名:
Project Settings > Signing & Capabilities > Hardened Runtime > Runtime Exceptions > Diable Library Validation
- 选项 2:使用您的代码签名身份对库进行代码签名,例如
Apple Development: Your Name (10-char-ID)
- 删除public签名:
codesign --remove-signature /path/to/theirlib.dylib
- 用项目签名签名:
codesign -s "Apple Development: Your Name (10-char-ID)" /path/to/theirlib.dylib
- 删除public签名: