在 Xcode 上包含来自添加框架的标头 [英] Include Headers from added frameworks on Xcode

查看:30
本文介绍了在 Xcode 上包含来自添加框架的标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用一些框架,如 glewcg 所以我手动添加了

I want to work with some frameworks like glew and cg so i manually added

通过右键单击项目来为我的项目添加所需的框架 -> 将文件添加到...

the needed frameworks to my project by right clicking the project -> Add files to ...

并选择正确的框架.问题是,当我尝试包含头文件时,

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 指令之后作为自动完成提供.如果它不起作用(有时会发生),我可以为您提供其他步骤.

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 的文档 可在此处获得状态:

Apple's documentation available here states:

  1. 在项目导航器中,选择你的项目
  2. 选择您的目标
  3. 选择构建阶段"标签
  4. 打开将二进制文件与库链接"扩展器
  5. 点击+"按钮
  6. 选择您的框架
  7. (可选)拖放添加的框架到框架"组

这篇关于在 Xcode 上包含来自添加框架的标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆