Skip to content

Instantly share code, notes, and snippets.

@phatblat
Created January 8, 2015 21:08
Show Gist options
  • Select an option

  • Save phatblat/04b8ef20654432ae6549 to your computer and use it in GitHub Desktop.

Select an option

Save phatblat/04b8ef20654432ae6549 to your computer and use it in GitHub Desktop.
Find the main app bundle from inside an extension bundle
NSBundle *bundle = [NSBundle mainBundle];
if ([[bundle.bundleURL pathExtension] isEqualToString:@"appex"]) {
// Peel off two directory levels - MY_APP.app/PlugIns/MY_APP_EXTENSION.appex
bundle = [NSBundle bundleWithURL:[[bundle.bundleURL URLByDeletingLastPathComponent] URLByDeletingLastPathComponent]];
}
NSURL *url = [bundle URLForResource:... withExtension:...];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment