如何将GPUImage添加到iOS项目? [英] How do you add GPUImage to an iOS project?

查看:242
本文介绍了如何将GPUImage添加到iOS项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个可以在图像上添加滤镜的相机/照片应用.我听说过布拉德·拉尔森(Brad Larson)的GPUImage,所以我下载了它并尝试对其进行操作,以使其对代码更加熟悉.

I am trying to make a camera/photo app that will add a filter on an image. I have heard of Brad Larson's GPUImage and so I downloaded it and tried to manipulate it to be more familiar with the code.

现在,我在Xcode中创建了一个新项目并将其添加到我的框架中,但是我不知道如何在新项目中使用它.

Now, I made a new project in Xcode and added it on my frameworks, but i don't have any idea how to use it on a new project.

如何在新项目中正确使用GPUImage?

How can I properly use GPUImage in my new project?

推荐答案

我不知道如何比在

I don't know how I could be much clearer than the step-by-step instructions I put on the very first page of the GitHub project and in the README.md under the section "Adding the framework to your iOS project":

一旦您有了该框架的最新源代码,它就相当 直接将其添加到您的应用程序.首先拖动 将GPUImage.xcodeproj文件插入应用程序的Xcode项目中以进行嵌入 您项目中的框架.接下来,转到您应用程序的目标 并添加GPUImage作为目标依赖项.最后,您需要拖动 GPUImage框架产品中的libGPUImage.a库 文件夹中的使用库链接二进制文件"构建阶段 应用程序的目标.

Once you have the latest source code for the framework, it's fairly straightforward to add it to your application. Start by dragging the GPUImage.xcodeproj file into your application's Xcode project to embed the framework in your project. Next, go to your application's target and add GPUImage as a Target Dependency. Finally, you'll want to drag the libGPUImage.a library from the GPUImage framework's Products folder to the Link Binary With Libraries build phase in your application's target.

GPUImage需要将其他一些框架链接到您的 应用程序,因此您需要将以下内容添加为链接库 在您的应用目标中:

GPUImage needs a few other frameworks to be linked into your application, so you'll need to add the following as linked libraries in your application target:

  • CoreMedia
  • CoreVideo
  • OpenGLES
  • AVFoundation
  • QuartzCore
  • CoreMedia
  • CoreVideo
  • OpenGLES
  • AVFoundation
  • QuartzCore

您还需要找到框架标头,因此在您的 项目的构建设置将Header Search Paths设置为相对 从您的应用程序到该框架内的framework/子目录的路径 GPUImage源目录.将此标头搜索路径设为递归.

You'll also need to find the framework headers, so within your project's build settings set the Header Search Paths to the relative path from your application to the framework/ subdirectory within the GPUImage source directory. Make this header search path recursive.

要在您的应用程序中使用GPUImage类,只需添加 核心框架标头使用以下内容:

To use the GPUImage classes within your application, simply include the core framework header using the following:

#import "GPUImage.h"

请注意:如果您遇到错误未知类GPUImageView 尝试使用以下命令创建接口时,"Interface Builder"等 Interface Builder,您可能需要将-ObjC添加到其他链接器 项目的构建设置中的标志.

As a note: if you run into the error "Unknown class GPUImageView in Interface Builder" or the like when trying to build an interface with Interface Builder, you may need to add -ObjC to your Other Linker Flags in your project's build settings.

此外,如果您需要将其部署到iOS 4.x,则似乎 当前版本的Xcode(4.3)要求您弱链接Core 最终应用程序中的视频框架,否则会崩溃 出现消息找不到符号:_CVOpenGLESTextureCacheCreate" 创建档案以上传到App Store或临时 分配.为此,请转到项目的构建阶段"标签, 展开使用库链接二进制文件"组,然后找到 列表中的CoreVideo.framework.在远处更改它的设置 列表中的从必需"到可选".

Also, if you need to deploy this to iOS 4.x, it appears that the current version of Xcode (4.3) requires that you weak-link the Core Video framework in your final application or you see crashes with the message "Symbol not found: _CVOpenGLESTextureCacheCreate" when you create an archive for upload to the App Store or for ad hoc distribution. To do this, go to your project's Build Phases tab, expand the Link Binary With Libraries group, and find CoreVideo.framework in the list. Change the setting for it in the far right of the list from Required to Optional.

此外,这是一个支持ARC的框架,因此如果要使用 在针对iOS 4.x的手动参考计数应用程序中, 您还需要在其他链接程序标记中添加-fobjc-arc.

Additionally, this is an ARC-enabled framework, so if you want to use this within a manual reference counted application targeting iOS 4.x, you'll need to add -fobjc-arc to your Other Linker Flags as well.

要查看实际效果,请查看框架附带的许多示例应用程序中的任何一个.

To see this in action, look at any of the many sample applications I ship with the framework.

这篇关于如何将GPUImage添加到iOS项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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