Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSMessage addCustomDesignFromFileWithName:@"AlternativeDesign.json"] crashes #175

Closed
aporat opened this issue Aug 27, 2014 · 10 comments
Closed

Comments

@aporat
Copy link

aporat commented Aug 27, 2014

after the recent changes [TSMessage addCustomDesignFromFileWithName:@"AlternativeDesign.json"] crashes when using a custom design.

this is due to the fact that the json file is looked up only inside the new bundle. specifically, this line causes the crash: 5908e4c#diff-66f9603ce433cc6cc7b4df87530f4b9bR76

@KrauseFx
Copy link
Owner

Oh, that makes sense. I'll publish a fix for that.

@KrauseFx
Copy link
Owner

Okay, fixed with 92fd1a9

It was only related to the example project. The method itself works in your project, right?

@aporat
Copy link
Author

aporat commented Aug 27, 2014

the issue still occurs in my app, I haven't tested the example project. perhaps the cocoapods spec is broken? it doesn't seem to find the TSDesignFileName in the pod bundle. my app crashes at https://github.com/toursprung/TSMessages/blob/92fd1a9c3db64615c11aa8d04cab955624457845/Pod/Classes/TSMessageView.m#L77 after I load a custom json design file.

If I add a fileExistsAtPath check on that line, the app runs fine, but im not sure what the side effects of that.

[NSManagedObjectContext(MagicalRecord) MR_setDefaultContext:](0xb52498) Set Default Context: <NSManagedObjectContext: 0xbf30570>
2014-08-27 09:59:05.331 xxxx[48490:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x038541e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x032fe8e5 objc_exception_throw + 44
    2   CoreFoundation                      0x03853fbb +[NSException raise:format:] + 139
    3   Foundation                          0x010f6bd2 +[NSJSONSerialization JSONObjectWithData:options:error:] + 67
    4   xxx                       0x0037ce69 +[TSMessageView notificationDesign] + 457
    5   xxx                       0x0037d0b8 +[TSMessageView addNotificationDesignFromFile:] + 440
    6   xxx                       0x0037c857 +[TSMessage addCustomDesignFromFileWithName:] + 103
    7   xxx                       0x0011ad15 -[AppDelegate application:didFinishLaunchingWithOptions:] + 5701
    8   UIKit                               0x01bc714f -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
    9   UIKit                               0x01bc7aa1 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1810
    10  UIKit                               0x01bcc667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
    11  UIKit                               0x01be0f92 -[UIApplication handleEvent:withNewEvent:] + 3517
    12  UIKit                               0x01be1555 -[UIApplication sendEvent:] + 85
    13  UIKit                               0x01bce250 _UIApplicationHandleEvent + 683
    14  GraphicsServices                    0x046fef02 _PurpleEventCallback + 776
    15  GraphicsServices                    0x046fea0d PurpleEventCallback + 46
    16  CoreFoundation                      0x037cfca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    17  CoreFoundation                      0x037cf9db __CFRunLoopDoSource1 + 523
    18  CoreFoundation                      0x037fa68c __CFRunLoopRun + 2156
    19  CoreFoundation                      0x037f99d3 CFRunLoopRunSpecific + 467
    20  CoreFoundation                      0x037f97eb CFRunLoopRunInMode + 123
    21  UIKit                               0x01bcbd9c -[UIApplication _run] + 840
    22  UIKit                               0x01bcdf9b UIApplicationMain + 1225
    23  xxxx                       0x000fccdd main + 141
    24  libdyld.dylib                       0x03fef6d9 start + 1
)

@KrauseFx
Copy link
Owner

That usually means, the file cannot be found. Can you check your [appname].app bundle if your JSON file exists? Set an exception breakpoint and see what's causing the crash.

@KrauseFx KrauseFx reopened this Aug 28, 2014
@ethanmick
Copy link

Using TSMessages pointed at :head, this crash occurs. Setting a breakpoint reveals that https://github.com/toursprung/TSMessages/blob/92fd1a9c3db64615c11aa8d04cab955624457845/Pod/Classes/TSMessageView.m#L72 podBundle is nil. Also, looking at my cocoapod structure, TSMessages has a "Resource" folder but doesn't have a bundle in it at all.

Do you have to create the .bundle yourself? Cocoapods seems to suggest you need to point the Podspec to a .bundle file.

@KrauseFx
Copy link
Owner

KrauseFx commented Oct 5, 2014

Well, TSMessages uses resource_bundles, like described here: http://guides.cocoapods.org/syntax/podspec.html#resource_bundles

Are you using Cocoapods for integrating this library?

@ethanmick
Copy link

Yep, although my Podfile points to :head to get some of the new features that have been added:

pod 'TSMessages', :head

It'll crash at that point because the podBundle variable isn't properly instantiated.

@KrauseFx
Copy link
Owner

KrauseFx commented Oct 5, 2014

Can you check if the resource bundle was properly installed with your app in the simulator?

@ethanmick
Copy link

Nope - inside my .app file I have the following:
screen shot 2014-10-05 at 10 24 47 am

It appears to grab the files in ./Assets and toss them into my Main Bundle, but doesn't create a .bundle file for them. I deleted my Derived Data, reinstalled TSMessages on 0.9.10, but the bundle still doesn't appear.

@KrauseFx
Copy link
Owner

KrauseFx commented Nov 3, 2014

All this should be fixed with the latest version on master. I'll release a Cocoapods update later today

@KrauseFx KrauseFx closed this as completed Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants