Datepicker iOS 14 crashes on completely empty project

Hi,

In my project I noticed that date-picker component keeps crashing on a specific dates.
Sending this error message:
"Invalid calculation: number of calculated days is not dividable by the number of days in a week.'"

Initially I thought it's something with my project and so on. But after that I had created a new project without any lines of code.

Steps to reproduce the error:
  1. Create new Xcode project

  2. Open Main.storyboard

  3. Drag datepicker from the "+"

  4. Run project

  5. tap over the datepicker and scroll to 1996

Note: This happens only if the date picker is with preferred style: compact and/or inline (default options).

youtu.be/hjskPTB0Ok8

I am using:
Big sur 11.2
Xcode Version 12.4 (12D4e)
Answered by Claude31 in 660604022
I looked at video and did the test with the same DatePicker configuration.

No crash.

I tested with 12Pro simulator. No crash.

Could you post the complete crash log, it is not possible to read on the video.

I am also using 12.4 (12D4e)
Tested on Catalina 10.15.7 (19H114)

What is your MacOS version ?

Maybe you have an Xcode installation issue ?

Steps to reproduce the error:
Create new Xcode project
Open Main.storyboard
Drag datepicker from the "+"
Run project
tap over the datepicker and scroll to 1996

I cannot reproduce the error following the steps here.
Do you know what is needed?
Hi,

Thanks for the attempt, I had created a video, maybe I am missing something?
Here is the video:

youtu.be/hjskPTB0Ok8

I am using: Version 12.4 (12D4e)
I tried and could not reproduce the crash.

I created a project for iOS (not multiplatform)
UIKit
Storyboard

I tested with 2 date pickers style:
  • on automatic

  • one as wheels

Mode is set to Date

Xcode 12.4
Tested on simulator iPhone 11 ProMax 14.4.
I scrolled to 1996.

No crash.

Could you describe your exact set up ?
Accepted Answer
I looked at video and did the test with the same DatePicker configuration.

No crash.

I tested with 12Pro simulator. No crash.

Could you post the complete crash log, it is not possible to read on the video.

I am also using 12.4 (12D4e)
Tested on Catalina 10.15.7 (19H114)

What is your MacOS version ?

Maybe you have an Xcode installation issue ?
Used OS version: Big sur 11.2
Here is the log:

2021-02-05 12:06:31.717666+0200 test2[50111:1553156] * Assertion failure in -[UIDatePickerCalendarDaySet daysForMonth:includingOverlapDays:], UIDatePickerCalendarDaySet.m:132

2021-02-05 12:06:31.768670+0200 test2[50111:1553156]
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid calculation: number of calculated days is not dividable by the number of days in a week.'
  • First throw call stack:

(

0   CoreFoundation                      0x00007fff20421af6 _exceptionPreprocess + 242

1   libobjc.A.dylib                     0x00007fff20177e78 objc
exceptionthrow + 48

2   CoreFoundation                      0x00007fff2042191f +[NSException raise:format:] + 0

3   Foundation                          0x00007fff2077156a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191

4   UIKitCore                           0x00007fff24bff44b -[
UIDatePickerCalendarDaySet daysForMonth:includingOverlapDays:] + 1338

5   UIKitCore                           0x00007fff241b37e3 -[UIDatePickerCalendarViewDataSourceController prepareDataSourceWithScrollPositionIfNecessary:] + 493

6   UIKitCore                           0x00007fff242a2223
112-[UIDatePickerCalendarDateView setVisibleMonth:animated:updateDataSource:updateCollectionView:notifyDelegate:]blockinvoke + 60

7   UIKitCore                           0x00007fff242a2275 -[
UIDatePickerCalendarDateView performIgnoringScrollCallbacks:] + 59

8   UIKitCore                           0x00007fff242a2184 -[
UIDatePickerCalendarDateView setVisibleMonth:animated:updateDataSource:updateCollectionView:notifyDelegate:] + 192

9   UIKitCore                           0x00007fff242a1afb -[
UIDatePickerCalendarDateView setSelectedDate:animated:updateVisibleMonth:updateCollectionView:notifyDelegate:] + 282

10  UIKitCore                           0x00007fff242a19db -[
UIDatePickerCalendarDateView setSelectedDate:animated:] + 40

11  UIKitCore                           0x00007fff23b4b8a3 -[UIDatePickerCalendarView updateSelectedDay:time:animated:notify:] + 936

12  UIKitCore                           0x00007fff23b4b9d8 -[UIDatePickerCalendarView updateSelectedDay:animated:notify:] + 106

13  UIKitCore                           0x00007fff23b4bbe2 -[UIDatePickerCalendarView updateSelectedDayToDayInMonth:animated:notify:] + 351

14  UIKitCore                           0x00007fff23b4c00e -[UIDatePickerCalendarView monthYearSelector:didSelectMonth:] + 60

15  UIKitCore                           0x00007fff24ad2c60 -[
UIDatePickerCalendarMonthYearSelector setSelectedMonth:animated:updatePicker:notifyDelegate:] + 236

16  UIKitCore                           0x00007fff24ad2d91 -[
UIDatePickerCalendarMonthYearSelector didSelectDate:] + 172

17  UIKitCore                           0x00007fff2469d19e -[UIApplication sendAction:to:from:forEvent:] + 83

18  UIKitCore                           0x00007fff23fc6684 -[UIControl sendAction:to:forEvent:] + 223

19  UIKitCore                           0x00007fff23fc69a7 -[UIControl
sendActionsForEvents:withEvent:] + 332

20  UIKitCore                           0x00007fff24615bf9 -[UIDatePickerView pickerView:didSelectRow:inComponent:] + 395

21  UIKitCore                           0x00007fff24621f65 -[UIPickerView
sendSelectionChangedForComponent:notify:] + 103

22  UIKitCore                           0x00007fff2461c2bd -[UIPickerTableView scrollingFinished] + 184

23  UIKitCore                           0x00007fff2461c4c0 -[UIPickerTableView scrollViewDidEndDecelerating:] + 27

24  UIKitCore                           0x00007fff24b8628a -[UIScrollView
scrollViewDidEndDeceleratingForDelegate] + 148

25  UIKitCore                           0x00007fff24b7ffc1 -[UIScrollView stopScrollDecelerationNotify:] + 560

26  UIKitCore                           0x00007fff24b80227 -[UIScrollView
stopScrollingNotify:pin:tramplingDragFlags:] + 508

27  UIKitCore                           0x00007fff248bfe42 -[UITableView stopScrollingNotify:pin:] + 42

28  UIKitCore                           0x00007fff24b75526 -[UIScrollView
smoothScrollWithUpdateTime:] + 3278

29  UIKitCore                           0x00007fff24b75794 -[UIScrollView smoothScrollDisplayLink:] + 395

30  QuartzCore                          0x00007fff279c32b9
ZN2CA7Display11DisplayLink14dispatchitemsEyyy + 755

31  QuartzCore                          0x00007fff27aa8dbc
ZL22displaytimercallbackP12_CFMachPortPvlS1 + 639

32  CoreFoundation                      0x00007fff2035d9d8 _CFMachPortPerform + 157

33  CoreFoundation                      0x00007fff20390c82 CFRUNLOOP
ISCALLINGOUTTOASOURCE1PERFORMFUNCTION + 41

34  CoreFoundation                      0x00007fff20390023
CFRunLoopDoSource1 + 614

35  CoreFoundation                      0x00007fff2038a4f2
CFRunLoopRun + 2353

36  CoreFoundation                      0x00007fff203896d6 CFRunLoopRunSpecific + 567

37  GraphicsServices                    0x00007fff2c257db3 GSEventRunModal + 139

38  UIKitCore                           0x00007fff24696cf7 -[UIApplication
run] + 912

39  UIKitCore                           0x00007fff2469bba8 UIApplicationMain + 101

40  libswiftUIKit.dylib                 0x00007fff551885f2 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98

41  test2                               0x00000001093ccaea $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 122

42  test2                               0x00000001093cca5e $s5test211AppDelegateC5$mainyyFZ + 46

43  test2                               0x00000001093ccb39 main + 41

44  libdyld.dylib                       0x00007fff2025a3e9 start + 1

45  ???                                 0x0000000000000001 0x0 + 1

)

libc++abi.dylib: terminating with uncaught exception of type NSException

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid calculation: number of calculated days is not dividable by the number of days in a week.'

terminating with uncaught exception of type NSException

CoreSimulator 732.18.6 - Device: iPhone 12 Pro (52D9022C-204E-4C1E-9596-1BFA46B08979) - Runtime: iOS 14.4 (18D46) - DeviceType: iPhone 12 Pro

(lldb) 
I was able to get a real device to test.
Seems to be working fine on it.
Maybe as pointed out by Claude31 it's either Xcode installation issue or something with the OS of the simulators.

Thanks for everyone's time.
I have encountered the same issue, 200++ crashes on the app I developed, hope Apple can provide a solution for that.

Error message from Crashlytics
Fatal Exception: NSInternalInconsistencyException
Invalid calculation: number of calculated days is not dividable by the number of days in a week.


The same here. Crashlytic reports this crash for 14.4.0 (18D52) on iPhone 7 Plus, so it's a real device, in a production app.
I'm seeing these crashes also, but only for Beirut (!). You can recreate by setting the device's time zone to Beirut, while leaving the current Region to United States (or any region other than Lebanon).

Force current Region to Lebanon in Edit Scheme -> Options -> App Region and it doesn't crash. But setting the picker's locale to en_LB (Lebanon) doesn't help.

There must be something specific about the mismatch of time zone and region for Lebanon but I haven't found it. A (poor) workaround might be to identify the mismatch and switch the picker.preferredDatePickerStyle to .wheel in that case only.
I agree with @3no, my timezone was set to Beirut, and I was facing crashes with date/time pickers. When changing it to Boston, US for example, it worked.
Maybe Beirut will be deleted from the map soon, lol!
@3no @eliaszaghrini.
did you find any solution to this?
I came not as a dev, but I had this error simply entering time in Calendar or Alarm. Thanks @3no, your tip resolved the issue for me too!
Met the same problem on iPhone 12 Pro simulator.
MacOS 11.2.3
iOS 14.4
Kyiv TimeZone

It is not reproduced on real iPhone X with iOS 14.4.2
Every one of my users who experienced this crash is in Lebanon/Beirut and is on iOS 14.4 and up
I have the same crash report showing up in crashlytics. iPhone XS iOS 14.4.2
Is this still not fixed by apple?


This was an issue with UIDatePicker and certain timezones that was addressed in iOS 14.5, which was released earlier this Spring.

For any kind of date picker issue, please also post the locale of your device, the calendar you are using and the time zone your device is set to.

Getting DatePickerMode crash in iPad Pro 12.9 inch iOS 15.2.1. Fatal

Exception: NSRangeException 0 CoreFoundation 0x91d3c __exceptionPreprocess 1 libobjc.A.dylib 0x146a8 objc_exception_throw 2 CoreFoundation 0x18a940 -[__NSCFString characterAtIndex:].cold.1 3 CoreFoundation 0x2cb04 __CFPropertyListIsDictPlistAux 4 UIKitCore 0x3e2950 -[UIPickerView selectedRowInComponent:] 5 UIKitCore 0xe285cc -[_UIDatePickerMode_Date _dateForYearRow:] 6 UIKitCore 0xe25658 -[_UIDatePickerMode dateForRow:inCalendarUnit:] 7 UIKitCore 0xe257c8 -[_UIDatePickerMode titleForRow:inComponent:] 8 UIKitCore 0xe26ec8 -[_UIDatePickerMode viewForRow:inComponent:reusingView:] 9 UIKitCore 0xe31f84 -[_UIDatePickerView pickerView:viewForRow:forComponent:reusingView:] 10 UIKitCore 0x530a44 -[UIPickerView tableView:cellForRowAtIndexPath:] 11 UIKitCore 0x4818c0 -[UIPickerColumnView tableView:cellForRowAtIndexPath:] 12 UIKitCore 0x27217c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] 13 UIKitCore 0x45fbe8 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] 14 UIKitCore 0x296d74 -[UITableView _updateVisibleCellsNow:] 15 UIKitCore 0x83998 -[UITableView _cellForRowAtIndexPath:usingPresentationValues:] 16 UIKitCore 0x406b70 -[UITableView cellForRowAtIndexPath:] 17 UIKitCore 0x3c6efc __61-[UIPickerTableView selectRow:animated:notify:updateChecked:]_block_invoke 18 Foundation 0x8a9a4 NSINDEXSET_IS_CALLING_OUT_TO_A_BLOCK 19 Foundation 0x1f70c __NSIndexSetEnumerate 20 UIKitCore 0x4c5604 -[UIPickerTableView selectRow:animated:notify:updateChecked:] 21 UIKitCore 0x49edb0 -[UIPickerView _selectRow:inComponent:animated:notify:] 22 UIKitCore 0xe306e4 -[_UIDatePickerView _selectRow:inComponent:animated:notify:] 23 UIKitCore 0xe25e8c -[_UIDatePickerMode loadDate:animated:] 24 UIKitCore 0xe3068c -[_UIDatePickerView _loadDateAnimated:] 25 UIKitCore 0xe2fbfc -[_UIDatePickerView didChangeDateFrom:animated:] 26 UIKitCore 0xe2fef4 -[_UIDatePickerView _setMode:] 27 UIKitCore 0xe3005c -[_UIDatePickerView didChangeMode] 28 UIKitCore 0xe1d160 -[UIDatePicker setDatePickerMode:] 29 DAWPatient 0x19a4b0 AboutMeViewController.configureDatePicker() + 116 (AboutMeViewController.swift:116) 30 DAWPatient 0x199874 AboutMeViewController.viewDidLoad() + 74 (AboutMeViewController.swift:74) 31 DAWPatient 0x199ef8 @objc AboutMeViewController.viewDidLoad() () 32 UIKitCore 0x19c6c8 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] 33 UIKitCore 0x19f03c -[UIViewController loadViewIfRequired] 34 UIKitCore 0x173554 -[UIViewController view] 35 UIKitCore 0x35c598 -[UINavigationController _startCustomTransition:] 36 UIKitCore 0x4ae0ac -[UINavigationController _startDeferredTransitionIfNeeded:] 37 UIKitCore 0x38df20 -[UINavigationController __viewWillLayoutSubviews] 38 UIKitCore 0x2bc720 -[UILayoutContainerView layoutSubviews] 39 UIKitCore 0x17d964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] 40 QuartzCore 0x3cb6c CA::Layer::layout_if_needed(CA::Transaction*) 41 QuartzCore 0x2fc58 CA::Layer::layout_and_display_if_needed(CA::Transaction*) 42 QuartzCore 0x433dc CA::Context::commit_transaction(CA::Transaction*, double, double*) 43 QuartzCore 0x4b8d4 CA::Transaction::commit() 44 QuartzCore 0x2f3b8 CA::Transaction::flush_as_runloop_observer(bool) 45 CoreFoundation 0x3dfc4 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION 46 CoreFoundation 0xf608 __CFRunLoopDoObservers 47 CoreFoundation 0xab9c __CFRunLoopRun 48 CoreFoundation 0x1de1c CFRunLoopRunSpecific 49 GraphicsServices 0x19a0 GSEventRunModal 50 UIKitCore 0x4ec600 -[UIApplication _run] 51 UIKitCore 0x281b08 UIApplicationMain 52 DAWPatient 0x6670 main + 19 (FirstOnBoardView.swift:19) 53 ??? 0x10473c250 (Missing)

Datepicker iOS 14 crashes on completely empty project
 
 
Q