To share code and resources between my application and extensions, I embed the Cocoa Touch Framework in my project, this environment contains some resources, such as images and xib files.
My question is: how do I access these resources from the main application and main extensions?
I used this method: iOS 8 Extension: how to use xib inside Cocoa Touch Framework in extensions?
but it will make a copy for all the resources in the bundle of applications and extensions , which is not a good repetition.
Is there a better way?
Update:
Now my main application can use this code to access the resource in the frameworks:
+(NSBundle*)frameworkBundle { NSString *frameworkDirPath = [[NSBundle mainBundle] privateFrameworksPath]; NSString *frameworkBundlePath = [frameworkDirPath stringByAppendingPathComponent:@"MyFramework.framework"]; NSBundle *frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath]; return frameworkBundle; }
but this does not work for extensions.
source share