0

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

i like cat
  • 135
  • 8

1 Answers1

0

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];
     //......
}
Yun CHEN
  • 6,450
  • 3
  • 30
  • 33
  • -(UIView *)getNibData { NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"IOS-Keypad.Keypad"]; if ([frameworkBundle pathForResource:@"Qwerty" ofType:@"nib"] != nil) { NSArray *nib = [frameworkBundle loadNibNamed:@"Qwerty" owner:self options:nil]; return [nib objectAtIndex:0]; } return nil; } but frameworkBundle is nil There is a picture above. – i like cat Nov 08 '17 at 01:28
  • Are these codes in Framework project? Or another project which uses the Framework? – Yun CHEN Nov 08 '17 at 01:39