0

Hey :) So I've been programming an app that I want to have available on the App Store. However, I have already submitted it twice with rejections concerning a crash when the app is played on an iPad (running 7.0.6 and 7.1, for both submits). The app works perfectly fine on my phone and on my mom's iPad, along with all the simulators. I also looked at the crash log (relevant info posted here):

Date/Time:           2014-03-15 14:29:04.504 -0700
OS Version:          iOS 7.1 (11D167)
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x182fb6950 __exceptionPreprocess + 132
1   libobjc.A.dylib                 0x18f9901fc objc_exception_throw + 60
2   CoreFoundation                  0x182ec0c7c -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 396
3   CoreFoundation                  0x182ec0ac4 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 72
4   Water Balloon                   0x1000b0be4 -[WBLogic updateScoreboard:] (WBLogic.m:406)
5   Water Balloon                   0x1000b0598 -[WBLogic checkCollision:] (WBLogic.m:341)
6   Water Balloon                   0x1000aff10 -[WBLogic update] (WBLogic.m:231)
7   SpriteKit                       0x185e47fb0 -[SKView(Private) _update:] + 236
8   SpriteKit                       0x185e45ab0 -[SKView renderCallback:] + 876
9   SpriteKit                       0x185e43794 __29-[SKView setUpRenderCallback]_block_invoke + 76
10  SpriteKit                       0x185e62a90 -[SKDisplayLink _callbackForNextFrame:] + 288
11  QuartzCore                      0x185bbccbc CA::Display::DisplayLinkItem::dispatch() + 36
12  QuartzCore                      0x185bbcac8 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 300
13  IOKit                           0x183eb7e74 IODispatchCalloutFromCFMessage + 364
14  CoreFoundation                  0x182f682e0 __CFMachPortPerform + 192
15  CoreFoundation                  0x182f76890 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
16  CoreFoundation                  0x182f767f0 __CFRunLoopDoSource1 + 444
17  CoreFoundation                  0x182f74a14 __CFRunLoopRun + 1620
18  CoreFoundation                  0x182eb56d0 CFRunLoopRunSpecific + 452
19  GraphicsServices                0x188b51c0c GSEventRunModal + 168
20  UIKit                           0x185fe6fdc UIApplicationMain + 1156
21  Water Balloon                   0x1000b1c38 main (main.m:16)
22  libdyld.dylib                   0x18ff83aa0 start + 4


Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x000000019007e58c __pthread_kill + 8
1   libsystem_c.dylib               0x0000000190012804 abort + 108
2   libc++abi.dylib                 0x000000018f238990 abort_message + 84
3   libc++abi.dylib                 0x000000018f255c28 default_terminate_handler() + 296
4   libobjc.A.dylib                 0x000000018f9904d0 _objc_terminate() + 124
5   libc++abi.dylib                 0x000000018f253164 std::__terminate(void (*)()) + 12
6   libc++abi.dylib                 0x000000018f252a7c __cxa_throw + 132
7   libobjc.A.dylib                 0x000000018f990314 objc_exception_throw + 340
8   QuartzCore                      0x0000000185bbcd7c CA::Display::DisplayLinkItem::dispatch() + 228
9   QuartzCore                      0x0000000185bbcac4 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 296
10  IOKit                           0x0000000183eb7e70 IODispatchCalloutFromCFMessage + 360
11  CoreFoundation                  0x0000000182f682dc __CFMachPortPerform + 188
12  CoreFoundation                  0x0000000182f7688c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
13  CoreFoundation                  0x0000000182f767ec __CFRunLoopDoSource1 + 440
14  CoreFoundation                  0x0000000182f74a10 __CFRunLoopRun + 1616
15  CoreFoundation                  0x0000000182eb56cc CFRunLoopRunSpecific + 448
16  GraphicsServices                0x0000000188b51c08 GSEventRunModal + 164
17  UIKit                           0x0000000185fe6fd8 UIApplicationMain + 1152
18  Water Balloon                   0x00000001000b1c34 main (main.m:16)
19  libdyld.dylib                   0x000000018ff83a9c start + 0

Usually a crash log would be useful in pointing out where the crash occurred, which would lead to why the crash occurred, but line 406 only points to this line in the code:

scorelabel.position = CGPointMake(width/2, height/2 + 150);

the entire method that this line is in is this:

- (void) updateScoreboard:(BOOL) on
{
    if(on)
    {
        int w = scoreboard.size.width;
        int h = scoreboard.size.height;

        if(score > highScore)
        {
            highScore = score;
            [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:highScore] forKey:@"HighScore"];
        }
        [highScorelabel setText:[NSString stringWithFormat:@"High Score: %i", highScore]];

        CGSize defs;
        CGSize ss;
        CGSize hs;

        defs = [@"Score: 1" sizeWithAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"04b_19" size:scorelabel.fontSize]}];
        ss = [[scorelabel text] sizeWithAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"04b_19" size:scorelabel.fontSize]}];
        hs = [[highScorelabel text] sizeWithAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"04b_19" size:highScorelabel.fontSize]}];

        scorelabel.position = CGPointMake(width/2 - w/4 - defs.width/2 + ss.width/2, scoreboard.position.y + h/4);
        highScorelabel.position = CGPointMake((scorelabel.position.x - ss.width/2) + hs.width/2, scorelabel.position.y - ss.height/2 - hs.height/2);
    }
    else
    {
        scorelabel.position = CGPointMake(width/2, height/2 + 150);
    }
    [scoreboard setHidden:!on];
    [taplabel setHidden:!on];
    [highScorelabel setHidden:!on];
}

I have no idea what the problem could be... Please help me find out why the app is causing their iPads to crash.

EDIT In response to the comment, height and width are determined like this:

width = scene.frame.size.width;
height = scene.frame.size.height;

Which is in - (id) init: (SKScene *) s. Also, I just found out that the entire time my app had been running with the logic scene inheriting from NSObject, not SKScene... Could that have had an influence (the app runs the same when I test it).

StrongJoshua
  • 975
  • 10
  • 24

1 Answers1

4

It is likely that the actual line of code in the symbolicated report is off by some lines. Since above the reported lines you actually do create dictionaries, and the crash is caused by an exception when creating a dictionary, it is likely that the crash happened. there.

So the lines in question are:

defs = [@"Score: 1" sizeWithAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"04b_19" size:scorelabel.fontSize]}];
ss = [[scorelabel text] sizeWithAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"04b_19" size:scorelabel.fontSize]}];
hs = [[highScorelabel text] sizeWithAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"04b_19" size:highScorelabel.fontSize]}];

And the dictionary is always the same:

@{NSFontAttributeName:[UIFont fontWithName:@"04b_19" size:highScorelabel.fontSize]}

So as a first step you should create a local variable for that dictionary and re-use that.

Now the crash is caused when creating the dictionary, since the exception message is missing in the crash report we have to guess here. One option is that you are trying to set a key to a nil value. So when can [UIFont fontWithName:@"04b_19" size:highScorelabel.fontSize] be nil?

The documentation doesn't really say, but I'd assume this can happen if the font with a given name cannot be found. So you should check if the font is really part of the app bundle you submitted to Apple. Then check if the fontName property is set to the correct value that also works on a device. The documentation says:

The fully specified name of the font. This name incorporates both the font family name and the specific style information for the font

This thread may provide an idea what can go wrong in that case: Crash with exception attempt to insert nil object from objects[0]

Community
  • 1
  • 1
Kerni
  • 15,241
  • 5
  • 36
  • 57
  • 3
    +1 very likely. Maybe [this question](http://stackoverflow.com/questions/10255141/uifont-fontwithname-returns-nil) is related? – lootsch Mar 16 '14 at 19:35
  • How would I check whether or not the font was included? Also, if it wasn't, then how come the app works perfectly on my phone, my iPad, and all the simulators? The only difference between the two is the provisioning profile which is changed to the distribution profile when I submit it. – StrongJoshua Mar 16 '14 at 19:39
  • I assume this is a custom font. So check if the file is included in the app bundle (e.g. unzip it) and check the related question @lootsch pointed out. – Kerni Mar 16 '14 at 19:44
  • @lootsch Thanks for posting that related question, number 4 in the advice could be a possibility. But how come the app works perfectly on my device, but not on theirs? – StrongJoshua Mar 16 '14 at 20:23
  • It was accepted :D https://itunes.apple.com/us/app/spikes-balloon/id829425162?ls=1&mt=8 – StrongJoshua Mar 22 '14 at 23:42