Skip to content

Instantly share code, notes, and snippets.

@sebk
Created December 4, 2014 19:02
Show Gist options
  • Save sebk/aa778a3708726d52683b to your computer and use it in GitHub Desktop.
Save sebk/aa778a3708726d52683b to your computer and use it in GitHub Desktop.
Get correct NSBundle for resource in a Cocoa Touch Framework
@import UIKit;
@interface NSBundle (Framework)
+ (NSBundle*)bundleForFramework;
@end
#import "NSBundle+Framework.h"
@implementation NSBundle (Framework)
+ (NSBundle*)bundleForFramework {
NSArray *bundz = [[NSBundle bundleForClass:[self class]] URLsForResourcesWithExtension:@"framework" subdirectory:nil];
for (NSURL *bundleURL in bundz){
// This should force it to attempt to load. Don't worry if it says it can't find a class.
NSBundle *child = [NSBundle bundleWithURL:bundleURL];
[child load];
}
return [NSBundle bundleWithIdentifier: @"INSERT CORRECT BUNDLE IDENTIFIER" ];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment