Search code examples
ios8ios8-extension

How to add the project prefix file to photo extension target?


The main target typically contains a -Prefix.pch file where all the convenience imports are defined. E.g when using opencv with c++ there is

#ifdef __cplusplus
    #import <opencv2/opencv.hpp>
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif

Unfortunately when using the new Photo Extension target in iOS 8, this file gets ignored making it a hassle to add all the files required in the extension target. Is there a way to make this Prefix file work also for the new target?

thx


Solution

  • You can change your extension's prefix header by changing your project's build settings. First, open the main project window in Xcode and select your photo extension target from the list on the left. Go to Build Settings -> Apple LLVM 6.0 - Language, then set Precompile Prefix Header to Yes and Prefix Header to your prefix header's path (you can copy this from the corresponding settings in your main application target). If you can't see these options, make sure All is selected at the top of the window instead of Basic.