添加库时 Xcode 给出错误:dyld: Library not returned

Lac*_*zet 2 c++ opengl xcode glfw

首先我想在xcode中学习SDL,但是当我尝试添加SDL框架时,会弹出这个错误,我不明白为什么。我在网上查了两天,但没有找到任何解决方案。1 个月后(现在)我尝试将 GLFW 添加到 xcode 但这个错误再次困扰了我。为什么会发生这个错误?

dyld: Library not loaded: /usr/local/opt/glfw/lib/libglfw.3.dylib
  Referenced from: /Users/durdukolk/Library/Developer/Xcode/DerivedData/Graphic-dutmtfjytmmfetggltqeajfkggms/Build/Products/Debug/Graphic
  Reason: no suitable image found.  Did find:
    /usr/local/opt/glfw/lib/libglfw.3.dylib: code signature in (/usr/local/opt/glfw/lib/libglfw.3.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/glfw/3.3.4/lib/libglfw.3.3.dylib: code signature in (/usr/local/Cellar/glfw/3.3.4/lib/libglfw.3.3.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.
Run Code Online (Sandbox Code Playgroud)

将二进制文件与库链接

搜索路径

Lac*_*zet 8

我终于找到了解决方案。首先,您需要在项目文件中的“签名”部分中打开“启用强化运行时”。 项目名称 -> 构建设置 -> 签名 -> 启用强化运行时

并且需要在产品菜单中选中“禁用库验证”。 目标名称 -> 签名和功能 -> 强化运行时 -> 禁用库验证

有关更多详细信息:https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_cs_disable-library-validation