Search code examples
iosswiftiphonecocoa-touchnsexception

[_LSDefaults sharedInstance]: unrecognized selector sent to class 0x20cbf3aa0


I recently up-graded the codebase to Xcode11.3, getting this error on launch without detailed logs:

2019-12-18 15:18:40.461627+0530 XXXXX[2485:622148] +[_LSDefaults sharedInstance]: unrecognized selector sent to class 0x20cbf3aa0
2019-12-18 15:18:40.462868+0530 XXXXX[2485:622148] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[_LSDefaults sharedInstance]: unrecognized selector sent to class 0x20cbf3aa0'
*** First throw call stack:
(0x1c512498c 0x1c4e4d0a4 0x1c502ccc8 0x1c578f50c 0x1c53df908 0x1c512ad90 0x1c4ffabd0 0x10c717cf8 0x10c71abc0 0x10c7242e4 0x10c723e78 0x10c7239d0 0x10c71f55c 0x10c77b5e4 0x10c7740f0 0x10c7ed5cc 0x10c7740f0 0x10c7b2f78 0x10c7d69b4 0x10c7b9f48 0x10c776e5c 0x10c7433bc 0x1c4e411ec 0x1c4e44aec)
libc++abi.dylib: terminating with uncaught exception of type NSException

Not sure what is wrong here, Is there any way I can get the actual class in code for this '0x20cbf3aa0'?

Note: This is only happening on Physical devices running iOS > 13


Solution

  • I found the root cause:

    Added NSSetUncaughtExceptionHandler to find the following stack trace.

    2019-12-18 16:37:55.892789+0530 XXXXX[2603:645006] Stack Trace: (   
    0   CoreFoundation                      0x00000001c51249a0 DA838E75-6B30-360E-9661-C4800A7E1BF6 + 1227168   
    1   libobjc.A.dylib                     0x00000001c4e4d0a4 objc_exception_throw + 56    
    2   CoreFoundation                      0x00000001c502ccc8 DA838E75-6B30-360E-9661-C4800A7E1BF6 + 212168    
    3   CoreServices                        0x00000001c578f50c 4631A29A-FFB2-3A9D-95FF-1037507BD066 + 840972    
    4   Foundation                          0x00000001c53df908 0DF2911E-80CB-3289-8A1E-ED0913D55A12 + 43272 
    5   CoreFoundation                      0x00000001c512ad90 DA838E75-6B30-360E-9661-C4800A7E1BF6 + 1252752   
    6   CoreFoundation                      0x00000001c4ffabd0 DA838E75-6B30-360E-9661-C4800A7E1BF6 + 7120  
    7   XXXXX                               0x00000001086d3cc0 - **[ONIMehtodId invokeWithTarget:Target:parameter:result:]** + 4372 
    8   XXXXX                               0x00000001086d6b88 fdwPRGInHj7S + 140   
    9   XXXXX                               0x00000001086e02ac fdioJuJ5X8sy + 60    
    10  XXXXX                               0x00000001086dfe40 fdfAYA5Knk6m + 1180  
    11  XXXXX                               0x00000001086df998 fderBiHVLVSO + 132   
    12  XXXXX                               0x00000001086db524 fdpriAImFRX8 + 5820  
    13  XXXXX                               0x00000001087375ac 10Qp8Dl9pVnp + 440   
    14  XXXXX                               0x00000001087300b8 108jVd8JFekR + 232   
    15  XXXXX                               0x00000001087a9594 10uqENVjb5qq + 244   
    16  XXXXX                               0x00000001087300b8 108jVd8JFekR + 232   
    17  XXXXX                               0x000000010876ef40 100iZEfbT6gW + 1608  
    18  XXXXX                               0x000000010879297c 10QzlTW4v2Ir + 56    
    19  XXXXX                               0x0000000108775f10 10yEsmvqVxay + 320   
    20  XXXXX                               0x0000000108732e24 10mN8k4ha1CN + 496   
    21  XXXXX                               0x00000001086ff384 10444cFtXXLs + 148   
    22  libsystem_pthread.dylib             0x00000001c4e411ec _pthread_start + 124 
    23  libsystem_pthread.dylib             0x00000001c4e44aec thread_start + 8)
    

    Observing the crash log at line 7 indicates that it's using ONIMethodId's method invokeWithTarget

    After that I inspected symbols (command - nm frameworkBinary ) for all my 3rd party frameworks, I got to know one of my framework was using this method which was eventually calling _LSDefaults private method. And that method has been deleted from iOS >= 13.0 SDK.

    I raised this to my 3rd party vendor and they'll provide an updated framework for the same.

    Thanks to everyone for comments and watching the issue, posting the answer so that it can help anyone else facing the same issue in future.