Objective C - Error loading bundle

3.8k views Asked by At

I'm working with a THEOS project. In my project, I want to use other frameworks or libraries with their's bundle resource (*.bundle) such as Google Plus framework. Because, this isn't a Xcode project so it hasn't Copy Bundle Resources section. I use NSBundle class to load bundle resource but I get this error

Error Domain=NSCocoaErrorDomain Code=4 "The bundle “MyBundle” couldn’t be loaded because its executable couldn’t be located." UserInfo=0x15a308d0 {NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSLocalizedFailureReason=The bundle’s executable couldn’t be located., NSLocalizedDescription=The bundle “MyBundle” couldn’t be loaded because its executable couldn’t be located., NSBundlePath=/var/mobile/Documents/MyBundle.bundle}

Here's my code

NSString *bundlePath = @"/var/mobile/Documents/MyBundle.bundle";
NSBundle *myBundle = [NSBundle bundleWithPath:bundlePath];
NSError *error;
BOOL loaded = [myBundle loadAndReturnError:&error];

NSLog(@"loaded: %@", (loaded ? @"TRUE" : @"FALSE"));
NSLog(@"error: %@", error);

I already try with other path and other bundle resource but I still get the same error

1

There are 1 answers

6
quellish On BEST ANSWER

You cannot load resources from outside your application bundle or bundle container. "/var/ mobile/Documents" is inaccessible to your application.

The actual error you are getting is that the system could not load the executable for the bundle. -loadAndReturnError: is for loading code in that bundle. You seem to be loading a bundle that has resources, but not executable code.