用 otool -L 查看应用链接的动态库

otool 能列出 macOS 可执行文件依赖的所有框架和 dylib——排查 dyld 库加载错误的第一步。

macOSMach-Ootool 二进制分析dyld 动态链接低风险
运行 `otool -L <binary>`,即可打印该可执行文件链接的全部共享库和框架。

01命令

命令
$ otool -L /Applications/SomeApp.app/Contents/MacOS/binary

02作用说明

otool -L 会列出 Mach-O 二进制需要的每个库,包括链接时记录的确切安装路径和版本号。当 dyld 报 "Library not loaded" 拒绝启动应用时,这份输出直接指出缺失的依赖及其预期路径。其他容易遗忘的参数:-hv 打印 Mach-O 头信息,-o 导出 Objective-C 类和方法选择器,-l 详细遍历加载命令。

03风险

风险低风险
使用条件Built-in on macOS (Xcode Command Line Tools).

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • otool(1) — object file displaying tool
    manpagez · technical · 2026-09-17
    依据: Man page documents -L to print the shared libraries each object file uses, plus -hv for headers and -o for Objective-C segments.
  • otool(1) manual page (macOS)
    unix.com · technical · 2026-09-17
    依据: Man page mirror documenting otool -L and other Mach-O inspection options.

最后验证: 2026-09-17 · 分类: 开发者