向XCode 4添加框架 [英] Adding a framework to XCode 4
问题描述
我当然在发表问题之前做了研究.
of course i did research before posting my question.
我看着
如何添加现有框架"在Xcode 4中?
在Xcode 4中添加框架
在Xcode 4中添加OpenGL框架
添加了dylib的XCode 4
I looked at
How to "add existing frameworks" in Xcode 4?
Adding Framework in Xcode 4
Adding an OpenGL framework in Xcode 4
XCode 4 adding dylib
但是整个事情都变得错误了.
but whole thing is becoming wrong.
我的目标:向XCode Mac项目添加(CorePlot)框架(不是iPhone)
My goal: Add (CorePlot) framework to XCode Mac project (not an iPhone one)
我的环境:OSX Lion 10.7,SDK Lion,XCode 4.1(4B110)
My environment: OSX Lion 10.7, SDK Lion, XCode 4.1 (4B110)
我的步骤:
- 打开XCode,创建新项目
- 将CorePlot下载到我的库目录中(例如〜/Applications/LIBS)
- 通过(+)打开的对话框打开项目首选项,以添加框架
- 添加现有框架(如果需要,可将文件复制到目标组中)
- 所选目录为〜/Applications/LIBS/CorePlot/Binaries/MacOS/CorePlot.framework/
- 将DnD CorePlot绘制到框架组
- 将CorePlot添加到
Build Phases > Link Binary with Libraries
- Opened XCode, created new project
- Downloaded CorePlot into my libraries directory (like ~/Applications/LIBS)
- Opened project preferences, via (+) opened dialog to add framework
- Add existing framework (+ copy files to dest. group if needed)
- Selected directory was ~/Applications/LIBS/CorePlot/Binaries/MacOS/CorePlot.framework/
- DnD CorePlot to Frameworks Group
- Added CorePlot to
Build Phases > Link Binary with Libraries
运行我的项目
我得到的是此错误消息:
what I got is this error message:
dyld: Library not loaded: @loader_path/../Frameworks/CorePlot.framework/Versions/A/CorePlot
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/metralight-hjuvuwlhgohrtdeepvcymnsaxomc/Build/Products/Debug/metralight.app/Contents/MacOS/metralight
Reason: image not found
实际上,当我查看给定目录(应用程序捆绑包)时,没有目录Frameworks
,因此链接无法成功
And in fact, when I looked into given directory (app bundle) there was no directory Frameworks
and so the linking cannot be successful
我又搜索了一次,发现可以创建Build Rule
并通过某些脚本将文件复制到最终的二进制文件包中,但这是这样做的唯一方法吗?
I have searched one more, and found, that I can create Build Rule
and copy files into final binary bundle via some script, but is this only way how to do this?
没有打开/关闭将链接的框架复制到最终捆绑包的选项吗?
Isn't there some option to just turn on/off copying linked frameworks to final bundle?
请注意,CorePlot目标'.framework'已将Dynamic Library Install Name
设置为@loader_path/../Frameworks/CorePlot.framework/Versions/A/CorePlot
,因此它在最终二进制文件包中的正确位置
Note that CorePlot target '.framework' has Dynamic Library Install Name
set to @loader_path/../Frameworks/CorePlot.framework/Versions/A/CorePlot
, so it is looking in right place in final binary bundle
推荐答案
通过添加现有框架"添加框架之后
After adding framework via "Add existing framework"
- 转到
Project Settings
>Build Phases
- 在右下角单击
Add buid phase
>Copy Files
- 选择目的地>
Frameworks
- 将框架拖放到文件列表中
- Go to
Project Settings
>Build Phases
- In right bottom corner click
Add buid phase
>Copy Files
- Select Destination >
Frameworks
- Drag&Drop framework to files list
就是这样.
这篇关于向XCode 4添加框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!