Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Crash when used with CocoaPods #19

Open
nickbit opened this issue Nov 10, 2017 · 0 comments
Open

Crash when used with CocoaPods #19

nickbit opened this issue Nov 10, 2017 · 0 comments

Comments

@nickbit
Copy link

nickbit commented Nov 10, 2017

Hello Bill,

I get a crash when adding the library with CocoaPods and have the use_frameworks! flag in the Podfile
The crash is in the following method:

+ (NSBundle *)bundle {
    static NSBundle *bundle = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSURL *url = [[NSBundle mainBundle] URLForResource:@"SORelativeDateTransformer" withExtension:@"bundle"];
        bundle = [[NSBundle alloc] initWithURL:url];
    });
    return bundle;
}

url is nil and it crashes the bundle initialization.

Here is a fix that you can add to avoid it:

+ (NSBundle *)bundle {
    static NSBundle *bundle = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSURL *url = [[NSBundle mainBundle] URLForResource:@"SORelativeDateTransformer" withExtension:@"bundle"];
        if (url != nil) {
            bundle = [[NSBundle alloc] initWithURL:url];
        } else {
            NSURL *frameworkURL = [[NSBundle bundleForClass:self] bundleURL];
            NSURL *bundleURL = [frameworkURL URLByAppendingPathComponent:@"SORelativeDateTransformer.bundle"];
            bundle = [NSBundle bundleWithURL:bundleURL];
        }
    });
    return bundle;
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant