Crash loadNibNamed (framework)

635 views Asked by At

I created the framework and it crashes when I loadNibNamed.

did not actually create the bundle file, and all the image and nib files are included in the framework.

image

-(Qwerty *)getNibData
{
    NSBundle *frameworkBundle = [NSBundle bundleForClass:[self class]];
    NSArray *nib = [frameworkBundle loadNibNamed:@"Qwerty" owner:self options:nil];

    return [nib objectAtIndex:0];
}

It works in debug mode but does not work in release.

Can you tell me the correct way to load a nib file from the framework?

and xcode is very hard;

If an error occurs

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

this shows the location and does not return an error code.

What information do I get from here?

-------------------------edit----------------------------------

image

1

There are 1 answers

2
Yun CHEN On

Create a bundle with framework id to load nib file:

NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.your.framework.id"];

if ([frameworkBundle pathForResource:@"Qwerty" ofType:@"nib"] != nil) {
     NSArray *nib = [frameworkBundle loadNibNamed:@"Qwerty" owner:self options:nil];
     //......
}