I am working on iOS 8 extension. I read many manuals and all of them just show how simple add extension to your app, and seems that's enough.
But here are many pitfalls:
After adding your extension you will need to import some of your classes to view controller that were created when you added new extension target. The big use here that you will need add all of them and if you have huge project it's not a simple task. Solution can be select extension target then in Build Phases -> Compile Sources press plus button and add all .m files to your target using hot key CMD+A.
After adding all files you can see that some of method wont work, and you can see this error:
'sharedApplication' is unavailable: not available on iOS (App Extension)
so the solution can be a macros that checkifndef Extension
then we can invokesharedApplication
code.#import <Foundation/Foundation.h>
vs#import <UIKit/UIKit.h>
. So I have not figured out with this issue but when I replacedFoundation
withUIKit
it works for me and all related issues go away.- CocoaPods. All of us are using CocoaPods so if your extension need to use some part of your project code and that code use CocoaPods library then you need to add
link_with 'ProjectTarged', 'ExtensionTarget'
to Pod file and makepod install
again to bind your libraries with new extension target.
So this is a main points I faced with. Maybe someone can suggest how to solve that issue, as I said I just import one needed file to extension view controller. The imported file contain some libraries like AFNetworking
, RestKit
and other nested classes from the main project. I need this class to invoke few methods with passing data from extension to my backend server. So one file but many issues.