How to add external framework GPUImage framework?

iSara picture iSara · Jun 28, 2012 · Viewed 10.4k times · Source

I am developing iPhone application using iOS. I need to add GPUImage framework, i followed this url for adding purpose. http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework

Now i drag and drop GPUImage xcodeproject file in my project. In this project product folder having libGPImage.a file. It showing empty folder, in this file missing. It showing like red color. I am unable to access GPUImage class files. why it is happening.

Thanks,

Answer

Brad Larson picture Brad Larson · Jul 1, 2012

As others have commented, I have step-by-step instructions for framework installation on the main GitHub page. I'll reproduce those below:

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 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

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.

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

#import "GPUImage.h"

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.

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.

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.

If you follow the steps in the first paragraph, when you drag the libGPUImage.a library from the Products folder into the Link Binary With Libraries build stage, it will indeed show up as red. The reason for this is that the static library has not been built yet at this stage. Don't worry about that, because if you follow the previous step of adding the project as a dependency of your application the static library will be built before your application is. Everything should work fine from this point on.

These are the installation instructions I've now used on several applications, and they've worked for each one.