在 Mac App Bundle 中嵌入框架 [英] Embedding frameworks in a Mac App Bundle
问题描述
我正在尝试将 SDL 和 SDL_ttf 框架添加到我的应用程序中,并且我已经按照通常的方式完成了它:将它们添加到将二进制文件与库链接"部分中,并添加了一个复制文件阶段,将它们复制到框架目录.这确实创建了一个带有嵌入式框架的应用程序包.但是,当我运行应用程序时,我收到此错误:
I'm trying to add SDL and SDL_ttf frameworks to my application and I've done it the usual way: added them in the "Link Binaries with Libraries" section and added a copy files phase that copies them to the Frameworks directory. This does create a app bundle with embedded frameworks. However, when I run the application, I get this error:
dyld:库未加载:@rpath/SDL_ttf.framework/Versions/A/SDL_ttf参考自:/Users/matthew.davies/Library/Developer/Xcode/DerivedData/MacHub-ambfqujqxbxyiqapaoctvsucpdeu/Build/Products/Release/MacHub.app/Contents/MacOS/MacHub原因:找不到图片
dyld: Library not loaded: @rpath/SDL_ttf.framework/Versions/A/SDL_ttf Referenced from: /Users/matthew.davies/Library/Developer/Xcode/DerivedData/MacHub-ambfqujqxbxyiqapaoctvsucpdeu/Build/Products/Release/MacHub.app/Contents/MacOS/MacHub Reason: image not found
我不知道还有什么办法可以让应用找到框架,尽管它已经嵌入到它的包中.
I am not sure what else to do so that the app can find the frameworks despite being embedded in its bundle.
有什么想法吗?
推荐答案
我在一个网页的评论中发现了原因.我需要将运行路径搜索路径"构建设置设置为@loader_path/../Frameworks"并找到框架.
I discovered the reason why in a comment on a webpage. I needed to set the "Runpath Search Paths" build setting to "@loader_path/../Frameworks" and the frameworks are found.
为什么没有在应用程序包的 Frameworks 目录中自动搜索框架对我来说完全是个谜?你在听苹果吗?:)
Why frameworks are not automatically searched for in the Frameworks directory of an app bundle is a complete mystery to me? Are you listening Apple? :)
这篇关于在 Mac App Bundle 中嵌入框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!