xcode 在 Mac App Bundle 中嵌入框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12499232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Embedding frameworks in a Mac App Bundle
提问by Cthutu
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:
我正在尝试将 SDL 和 SDL_ttf 框架添加到我的应用程序中,我已经按照通常的方式完成了:将它们添加到“链接二进制文件与库”部分,并添加了一个复制文件阶段,将它们复制到 Frameworks 目录。这确实创建了一个带有嵌入式框架的应用程序包。但是,当我运行该应用程序时,出现此错误:
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
dyld:库未加载:@rpath/SDL_ttf.framework/Versions/A/SDL_ttf 引用自:/Users/matthew.davies/Library/Developer/Xcode/DerivedData/MacHub-ambfqujqxbxyiqapaoctvsucpdeu/Build/Products/Release/MacHub.目录/MacOS/MacHub 原因:找不到图像
I am not sure what else to do so that the app can find the frameworks despite being embedded in its bundle.
我不知道还有什么办法可以让应用程序可以找到框架,尽管它被嵌入到了它的包中。
Any ideas please?
请问有什么想法吗?
采纳答案by Cthutu
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.
我在网页上的评论中发现了原因。我需要将“运行路径搜索路径”构建设置设置为“@loader_path/../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? :)
为什么没有在应用程序包的 Frameworks 目录中自动搜索框架对我来说是个谜?你在听苹果吗?:)