objective-c - 如果框架从应用程序中删除,会发生什么情况?

标签 objective-c macos cocoa frameworks

我被问到一个问题,如果从您的设备(可能是 iphone 或 mac)中意外删除了一个框架,会发生什么情况?

您的应用程序是崩溃了还是正常运行?

请给我提供解释的答案。

最佳答案

您可能会遇到链接错误。如果框架文件夹在应用程序内部意味着它的运行时链接。

OS X embeds an "install name" inside each dynamic library. This install name is the path to where the library can be found when dyld needs to load it. When you build an application that links against a dynamic library, this install name is copied into the application binary. When the application runs, the copied install name is then used to locate the library or framework.

   $ otool -D /Applications/Google\ Drive.app/Contents/Frameworks/Python.framework/Versions/2.6/Python 
    /Applications/Google Drive.app/Contents/Frameworks/Python.framework/Versions/2.6/Python:
    @executable_path/../Frameworks/Python.framework/Versions/2.6/Python  

因此,如果您要删除 Frameworks 文件夹,您将收到 Dyld 错误。

Dyld Error Message:
  Library not loaded: @loader_path/../Frameworks/Sparkle.framework/Versions/A/Sparkle
  Referenced from: /Applications/Transmission.app/Contents/MacOS/Transmission
  Reason: image not found  

enter image description here

enter image description here

关于objective-c - 如果框架从应用程序中删除,会发生什么情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15023498/

相关文章:

macos - 如何在pycharm中配置golang插件?

objective-c - 改变 NSPopover 的外观?

objective-c - UIButton 不可点击

iphone - ipad 中的 itunes 库工具

objective-c - 从2个或更多MKPolygon对象的交集创建MKPolygon

objective-c - 如何从 cocoa 中的 CFTypeRef 获取窗口号?

objective-c - 我可以在 NSView 的工具提示内添加超链接吗?

objective-c - NSTextField 不可编辑时自动增加宽度

objective-c - 带值的 NSArray

iOS8 - 裁剪和拉直图像作为内置照片工具