19

My app (iOS 8 only) has been rejected due to a crash when IAP are attempted. I've tried pretty much every incantation of the purchase process in an AdHoc build but cannot reproduce a crash. Looking at the crash log that the review team attached, I am seeing a very weird stack trace in the last exception backtrace. The crash looks to be involving UIPopoverController, however my app, though universal, does not explicitly or implicitly display popovers anywhere. Does anyone have any idea what might trigger the activity that is causing this crash? What might cause my app to display popovers when the review team is looking at it only?

Last Exception Backtrace:
0   CoreFoundation                0x186d52084 __exceptionPreprocess + 132
1   libobjc.A.dylib               0x1977a40e4 objc_exception_throw + 60
2   UIKit                         0x18bc0aee0 -[UIPopoverPresentationController presentationTransitionWillBegin] + 2464
3   UIKit                         0x18b7d27d8 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1324
4   UIKit                         0x18b7d1310 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 212
5   UIKit                         0x18b557388 _applyBlockToCFArrayCopiedToStack + 356
6   UIKit                         0x18b4c8e4c _afterCACommitHandler + 532
7   CoreFoundation                0x186d0a388 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
8   CoreFoundation                0x186d07314 __CFRunLoopDoObservers + 360
9   CoreFoundation                0x186d076f4 __CFRunLoopRun + 836
10  CoreFoundation                0x186c35664 CFRunLoopRunSpecific + 396
11  GraphicsServices              0x18fd435a4 GSEventRunModal + 168
12  UIKit                         0x18b53a984 UIApplicationMain + 1488
nickbona
  • 1,374
  • 1
  • 11
  • 23
  • 2
    Do you display a UIActivityViewController at any point? If so you're probably [crashing when displayed on an iPad](http://stackoverflow.com/questions/25644054/uiactivityviewcontroller-crashing-on-ios8-ipads). It seems in iOS8 Apple will display random bits of UI in this. Look for places where you present a UIViewController and try setting the required info on the `popoverPresentationController` property of the VC. Which is iOS8 only, so you need to check that it responds to that selector. – i_am_jorf Sep 24 '14 at 14:42
  • I do present an activity view controller, but nowhere in the flow they are citing when the app was rejected. I'm also not clear on why that would be a problem under app review only, and not in AdHoc release builds. – nickbona Sep 24 '14 at 15:01
  • It could be you're catching the exception in your builds but Apple breaks on the exception throw point? I can't speak to what Apple did, but I was thinking you may not have tested on iPad? It *shouldn't* be different on adhoc distributions, so if your activity view controller works on iPad for you locally, that must not be the problem. But like I said, one of your view controllers is ending up in this presentation popover thingy. – i_am_jorf Sep 24 '14 at 19:54
  • I have similar issue. However, I do not display either UIActivityViewController or UIPopoverPresentation controller at any point in my app. Crash seems to happen on both iPhone and iPad according to Splunk on iOS 8 devices only. Any ideas? – user2246051 Oct 11 '14 at 16:43
  • @i_am_jorf You should add that as an answer. I just found this question, and your suggestion of looking for uses of UIActivityViewController was the fix for me. – Nerrolken May 27 '15 at 21:09

4 Answers4

8

Not sure if it's the same cause as the original question, but I have the exact same error and the issue was using a UIAlertController with an ActionSheet style, presenting it worked fine on iPhone but iPad requires a sourceview to be set - https://stackoverflow.com/a/24233937/285694

Community
  • 1
  • 1
BadPirate
  • 25,802
  • 10
  • 92
  • 123
  • 2
    Omg - I literally have the exact same issue. – C. Tewalt Sep 27 '19 at 18:05
  • I have the exact same issue. Works on iPhone, crash on iPad. But: should we set setModalPresentationStyle:UIModalPresentationPopover]; and sourceView only for iPad or for both? – dowi Oct 22 '19 at 12:56
  • In my experience, you can go ahead and set them for iPhone and iPad with no harm. I too am still hunting occurrences of this bug despite having gone through the entire codebase twice looking for needles. It doesn't help that the crash gives no information about the location of the problem. – Paul Bruneau Nov 19 '19 at 15:30
0

This is a just similar situation. I had a crash bug on [UIPopoverPresentationController presentationTransitionWillBegin] on iOS 9+, and turns out that the crash occurred when sourceView was nil.

Example (in Objective-C):

UIViewController *vc = <#instance#>.
vc.modalPresentationStyle = UIModalPresentationPopover;
vc.popoverPresentationController.delegate = self;
vc.popoverPresentationController.sourceView = sourceView; // <--- this MUST NOT be nil.
vc.popoverPresentationController.sourceRect = sourceView.bounds;
[self presentViewController:vc animated:YES completion:nil];
Joey
  • 2,912
  • 2
  • 27
  • 32
0

It most probable the ActionSheet crash in iPad.

You should have a if condition like:

if let popoverController = alertVC.popoverPresentationController {
    popoverController.sourceView = self.view
    popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
    popoverController.permittedArrowDirections = []
  }
yuanjilee
  • 429
  • 5
  • 16
-1

First you should check UIPopoverPresentationController available or not.

NSArray *Items = [NSArray arrayWithObjects:emailBody,anImage, nil];

    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:Items applicationActivities:nil];

    if ([UIPopoverPresentationController class] != nil) {   
        UIPopoverPresentationController *popover = activityController.popoverPresentationController;
        if (popover)
        {
            popover.sourceView = sender;
            //popover.sourceRect = sender.bounds;
            popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
        }
    }


    [self presentViewController:activityController animated:YES completion:NULL];  
Rajesh
  • 10,318
  • 16
  • 44
  • 64
  • UIPopoverPresentationController class not found compiler in ipad-ios8 or above so app is crash . so first we are check UIPopoverPresentationController class available or not – Ambuj Chaudhary Nov 06 '14 at 06:37