Wednesday, 5 November 2014

What should you do if you can't find the GPUImage.h header for the GPUImage framework?

Adding GPUImage framework to XCode project could be tricky. So I haved added detailed step-by-step instructions w/ images on how to do it.
Static Compilation Method (detailed solution so we don't mess up)
This is Static compilation method. In this basically we will compile the framework using ./build.sh file. And simply add it to our XCode project, then configure XCode to properly use it.
  1. Download GPUImage from Github and extract it (or just clone it).
  2. Go to the GPUImagefolder in terminal
  3. Run ./build.sh
    Note: This will compile and create ready-to-use binary for all the sdks on your mac.
  4. build.sh creates a folder called build and generates compiled binaries and dumps them to folders like:Release-iPhoneRelease-iPhoneOSRelease-iphonesimulator etc folders. enter image description here
  5. For iPhone use Release-iphone (This also works for simulator).
  6. Copy (not drag-drop) Release-iphone to your XCode project's root directory so that we have a local copy of framework.
  7. Now iPhone drag-and-drop Release-iphone onto your XCode project. Make sure to check "Copy to .." option.
    Note:
    • This Release-iphone folder contains two sub-folders: include and lib
    • include folder contains all the header .h files
    • lib folder contains compiled binary version file called libGPUImage.a
    • We now need to simply configure XCode to use .h and .a files.**
  8. Select your project in the project explorer > Project name under Targets > select Build Phases > Expand Link Binary With Libraries
  9. Add the libGPUImage.a to Link Binary With Libraries section. You may want to Right-click onlibGPUImage.a then Open in Finder and finally drag-drop it.
  10. While we are at it, also add the following GPUImage's dependent frameworks/ libraries CoreMedia, CoreVideo, OpenGLES, AVFoundation, QuartzCore to Link Binary With Libraries section enter image description here
  11. Now, lets configure .h headers.
  12. Select your project in the project explorer > Project name under Targets > select Build Settings > and type search paths to see search paths section.
  13. Open Headers Search Paths by clicking on the value field.
  14. Drag-and-drop the lib folder to that popup. Note: If it shows absolute path, change it to looks$(SRCROOT)/path/to/lib/. (You should have the framework relative to your xcode project see step 6).
  15. Repeat 11 & 12 for Library Search Paths as well.
enter image description hereAdditional tips: You can add .h files to Library Search Paths or Headers Search Paths, you can make them Recursive. I have a main root-folder called Dependencies folder where I keep all the dependencies like MySDK-framework including Release-iPhone. And I just have one search-path at the Dependencies (root folder) and made it recursive.

No comments:

Post a Comment