TSMessages
TSMessages copied to clipboard
TSMessageView ios9 crash
-
(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; }
+1
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
I was able to work around the issue by adding the TSMessagesDefaultDesign.json to the "copy bundle resources" section in project Build Phases
I think it's something related to the new CocoaPods version
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.
use framework's bundle instead of app's bundle
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:TSDesignFileName ofType:@"json"];
The fix by @max-potapov works. Thank you! May we have a PR?
g *path = [[NSBundle bundleForClass:[self class]] pathForResource:TSDesignFileName ofType:@"json"]; is not helpful for me
@Brian-Chen049 Change that line in TSMessageView.m in notificationDesign
function.
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