TSMessages icon indicating copy to clipboard operation
TSMessages copied to clipboard

TSMessageView ios9 crash

Open guakeliao opened this issue 9 years ago • 10 comments

  • (NSMutableDictionary *)notificationDesign { if (!_notificationDesign) { NSString *path = [[NSBundle mainBundle] pathForResource:TSDesignFileName ofType:@"json"]; NSData *data = [NSData dataWithContentsOfFile:path]; NSAssert(data != nil, @"Could not read TSMessages config file from main bundle with name %@.json", TSDesignFileName);

    _notificationDesign = [NSMutableDictionary dictionaryWithDictionary:[NSJSONSerialization JSONObjectWithData:data
                                                                                                        options:kNilOptions
                                                                                                          error:nil]];
    

    }

    return _notificationDesign; }

guakeliao avatar Oct 10 '15 09:10 guakeliao

+1

adamszeptycki avatar Oct 10 '15 14:10 adamszeptycki

Here, in better markdown:

    + (NSMutableDictionary *)notificationDesign
    {
        if (!_notificationDesign)
        {
            NSString *path = [[NSBundle mainBundle] pathForResource:TSDesignFileName ofType:@"json"];
            NSData *data = [NSData dataWithContentsOfFile:path];
            NSAssert(data != nil, @"Could not read TSMessages config file from main bundle with name %@.json", TSDesignFileName);

            _notificationDesign = [NSMutableDictionary dictionaryWithDictionary:[NSJSONSerialization JSONObjectWithData:data
                                                                                                                options:kNilOptions
                                                                                                                  error:nil]];
        }

        return _notificationDesign;
    }

This results in a direct crash on iOS9:

 <Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not read TSMessages config file from main bundle with name TSMessagesDefaultDesign.json'

iOS9 can't find the right bundle probably :s This might also be related to how Cocoapods creates bundles, or iOS9 handling them... Might use resource_bundle in podspec

domingguss avatar Oct 20 '15 15:10 domingguss

I was able to work around the issue by adding the TSMessagesDefaultDesign.json to the "copy bundle resources" section in project Build Phases

guy-shahine avatar Oct 23 '15 06:10 guy-shahine

I think it's something related to the new CocoaPods version

mRs- avatar Oct 23 '15 07:10 mRs-

I got the same issue and it was caused by use_frameworks! in my pod file for a obj-c, swift bridging hell.

I used first https://github.com/CocoaPods/cocoapods-deintegrate to deintegrate the complete cocoapods integration and afterwards i run pod install again.

mRs- avatar Oct 23 '15 12:10 mRs-

use framework's bundle instead of app's bundle

NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:TSDesignFileName ofType:@"json"];

max-potapov avatar Nov 02 '15 15:11 max-potapov

The fix by @max-potapov works. Thank you! May we have a PR?

zkirill avatar Nov 09 '15 02:11 zkirill

g *path = [[NSBundle bundleForClass:[self class]] pathForResource:TSDesignFileName ofType:@"json"]; is not helpful for me

brianchen003 avatar Nov 20 '15 07:11 brianchen003

@Brian-Chen049 Change that line in TSMessageView.m in notificationDesign function.

zkirill avatar Nov 20 '15 07:11 zkirill

I know it's been a while, but here's a fork by @svlaev with the fix @max-potapov mentions: https://github.com/svlaev/TSMessages/blob/master/Pod/Classes/TSMessageView.m#L148

tonchis avatar Mar 24 '16 16:03 tonchis