Segment framework make UIAlertController to crash

2019-09-19 23:58发布

问题:

I follow "https://segment.com/" to implement analytics user usage on my iOS source. But when i use UIAlertController to show alert with title is @"", my app was crash! I don't know exactly why. To solve it, i must set title of alert is nil. And this is my logs:

2016-11-10 17:12:57.185 Lightning Rider Partner[24434:236155] *** Assertion failure in -[SEGAnalytics screen:properties:options:](), /Users/dungdo/Desktop/tcourier-ios/v2_driver/Pods/Analytics/Analytics/Classes/SEGAnalytics.m:323
2016-11-10 17:12:57.192 Lightning Rider Partner[24434:236155] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'screen name () must not be empty.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010c1f134b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00000001120f521e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010c1f5442 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x0000000111cc1d79 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
    4   Analytics                           0x000000010bc29d37 -[SEGAnalytics screen:properties:options:] + 471
    5   Analytics                           0x000000010bc3fb7c -[UIViewController(SEGScreen) seg_viewDidAppear:] + 444
    6   UIKit                               0x000000010e50eb0c -[UIViewController _setViewAppearState:isAnimating:] + 945
    7   UIKit                               0x000000010e51187a __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 42
    8   UIKit                               0x000000010e50fb64 -[UIViewController _executeAfterAppearanceBlock] + 86
    9   UIKit                               0x000000010e374438 _runAfterCACommitDeferredBlocks + 653
    10  UIKit                               0x000000010e360f6f _cleanUpAfterCAFlushAndRunDeferredBlocks + 566
    11  UIKit                               0x000000010e3923da _afterCACommitHandler + 176
    12  CoreFoundation                      0x000000010c195e17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    13  CoreFoundation                      0x000000010c195d87 __CFRunLoopDoObservers + 391
    14  CoreFoundation                      0x000000010c17ab9e __CFRunLoopRun + 1198
    15  CoreFoundation                      0x000000010c17a494 CFRunLoopRunSpecific + 420
    16  GraphicsServices                    0x0000000115145a6f GSEventRunModal + 161
    17  UIKit                               0x000000010e367964 UIApplicationMain + 159
    18  Lightning Rider Partner             0x000000010ad74c3f main + 111
    19  libdyld.dylib                       0x00000001128a868d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

回答1:

I was getting the same issue while using the Segment framework.

I just comment the Assert statement in SDK file for empty screen. Please search line below in your whole project and comment it out.

NSCAssert1(screenTitle.length > 0, @"screen name (%@) must not be empty.", screenTitle);

You are good to go.



回答2:

This seems like the error Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'screen name () must not be empty.

Make sure you already set it while creating SEGAnalytics class or something related