natjs / nat

A powerful kit for adding native functionalities to your weex app.
http://natjs.com
282 stars 25 forks source link

iPhone XR Termination #57

Open dseeker opened 5 years ago

dseeker commented 5 years ago

using device info for weex ios app, works fine in iOS12 for other models, but for XR it crashes, most likely due to unexpected version of the phone?

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[3]'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010addd29b __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x000000010a379735 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010ad278fc _CFThrowFormattedException + 194
    3   CoreFoundation                      0x000000010ae4c5a1 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 321
    4   CoreFoundation                      0x000000010add8d7b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
    5   realeyz                             0x0000000104c0f2b1 -[NatDeviceInfo deviceProperties] + 721
    6   realeyz                             0x0000000104c0ec6e -[NatDeviceInfo info:] + 94
    7   realeyz                             0x0000000104c5158d -[WeexNatDeviceInfo info:] + 189
    8   CoreFoundation                      0x000000010ade411c __invoking___ + 140
    9   CoreFoundation                      0x000000010ade15b5 -[NSInvocation invoke] + 325
    10  realeyz                             0x0000000104d5b6a9 __53-[WXModuleMethod _dispatchInvocation:moduleInstance:]_block_invoke + 57
    11  realeyz                             0x0000000104d5b74f __53-[WXModuleMethod _dispatchInvocation:moduleInstance:]_block_invoke.169 + 47
    12  realeyz                             0x0000000104dfd8c6 +[WXUtility _performBlock:] + 70
    13  Foundation                          0x000000010799ae7b __NSThreadPerformPerform + 330
    14  CoreFoundation                      0x000000010ad40b31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x000000010ad403a3 __CFRunLoopDoSources0 + 243
    16  CoreFoundation                      0x000000010ad3aa4f __CFRunLoopRun + 1263
    17  CoreFoundation                      0x000000010ad3a221 CFRunLoopRunSpecific + 625
    18  GraphicsServices                    0x000000010d1641dd GSEventRunModal + 62
    19  UIKitCore                           0x00000001128f3115 UIApplicationMain + 140
    20  realeyz                             0x0000000104bd6a06 main + 214
    21  libdyld.dylib                       0x000000010b563551 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
dseeker commented 5 years ago

added this to line 73 of NatDeviceInfo.m, it works now

        @"iPhone11,2": @"iPhone XS",
        @"iPhone11,4": @"iPhone XS Max",
        @"iPhone11,6": @"iPhone XS Max",
        @"iPhone11,8": @"iPhone XR",

but for the future it would be good to have a function that can return "unknown" when a new device is released