包括来自Xcode上已添加框架的标题 [英] Include Headers from added frameworks on Xcode
问题描述
我想使用glew
和cg
之类的框架,因此我手动添加了
I want to work with some frameworks like glew
and cg
so i manually added
所需的框架.
,然后选择正确的框架.问题是,当我尝试包含头文件时,
and choosing the correct framework. The problem is, when i try to include the header files,
Xcode找不到任何一个.我希望这张照片能帮助您理解:
Xcode cant find any of them. I hope this picture will help to understand:
并且:
给出的错误是针对glew
框架的,但也发生在Cg
上.
The error given is for the glew
framework, but it also happens on Cg
.
如您在左侧看到的,已添加了所需的框架.
As you can see on the left, The needed frameworks were added.
关于如何包含这些标头的任何想法吗?
Any idea on how i can include these headers?
尝试手动添加头文件后,出现体系结构错误:
After trying to add the header files manually i got an architecture error:
我不知道这是什么样子. 谢谢!
I dont know if this is how it should look like. Thanks!
推荐答案
在开始之前,请删除该框架以及在尝试使其正常工作时添加的所有文件.
Before starting, remove the framework and all files you have added while trying to make it work.
然后,您必须在目标的Build Phases
中添加框架.然后进入Link Binary With Libraries
并从那里选择您的框架.
Then, you have to add the frameworks in the Build Phases
of your target. Then go into Link Binary With Libraries
and select your framework from there.
这应该做到.每个#import directive.
之后,您的标头应可作为自动完成功能使用
如果它不起作用(有时会发生),我可以为您提供其他步骤.
This should do it. Your headers should be available as auto-completion after each #import directive.
If it does not work (it sometimes happens), there are additional steps I can provide to you.
其他步骤:
在构建设置中转到项目设置:
Go to your project settings, in the build settings:
- 用框架的路径完成
Framework Search Paths
- 对
User Header Search Path
执行相同操作
- Complete the
Framework Search Paths
with the path of your framework - Do the same with
User Header Search Path
然后,它应该可以工作.如果不是,则需要在#import
指令中添加标头的完整路径.示例:
Then, it should work. If it does not, you will need to add the full path of your header in the #import
directive. Example:
#import "/path/to/my/header.h"
Apple's documentation available here states:
- 在项目导航器中,选择 您的项目
- 选择目标
- 选择构建阶段"标签
- 打开与库链接二进制文件" 扩展器
- 点击"+"按钮
- 选择您的框架
- (可选)拖放添加的 框架加入框架"组
- In the project navigator, select your project
- Select your target
- Select the 'Build Phases' tab
- Open 'Link Binaries With Libraries' expander
- Click the '+' button
- Select your framework
- (optional) Drag and drop the added framework to the 'Frameworks' group
这篇关于包括来自Xcode上已添加框架的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!