WenchaoD / FSCalendar

A fully customizable iOS calendar library, compatible with Objective-C and Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App Crash when Timezone is America/Mazatlan

ravalzankhan opened this issue · comments

I used pod version (2.8.4) in the iOS App and the app crashed when the Timezone is America/Mazatlan and got the below error. It happens on iOS 17 and above.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempted to modify the selection of an out-of-bounds item (57) when there are only 42 items in section 647. Collection view: <FSCalendarCollectionView: 0x13f869e00; baseClass = UICollectionView; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x1424f1090>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x1424f0760>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}; layout: <FSCalendarCollectionViewLayout: 0x1424efd80>; dataSource: <FSCalendar: 0x1424a7050; frame = (8 0; 398 300); clipsToBounds = YES; hidden = YES; autoresize = RM+BM; backgroundColor = UIExtendedGrayColorSpace 0 1; layer = <CALayer: 0x1403c3c20>>>.'
*** First throw call stack:
(0x19838979c 0x19095b6a8 0x197940dc0 0x19a6f17b0 0x19a6f05e8 0x19a6f0584 0x104ceb43c 0x104ceaac4 0x104ceaa48 0x102d03c98 0x102cee160 0x102cffa60 0x19a4f8830 0x19a4f846c 0x19a4d5a50 0x19a4d5354 0x19a4d4a44 0x19a4d49ac 0x19a3f9c28 0x1998607e0 0x19986036c 0x199866500 0x19985fae0 0x19985f794 0x1982d8ba0 0x1982d7654 0x1982d6cf4 0x1982d6824 0x1d6af29fc 0x19a5db7f0 0x19a5dae5c 0x19a7d96b0 0x102b33f10 0x102b33e88 0x102b55d54 0x1b8daf9c4)
libc++abi: terminating due to uncaught exception of type NSException

one more logs for this crash

  1. Assertion failure in -[FSCalendarCollectionView _validateSelectionOrHighlightIndexPath:isSelection:allowMassIndexPath:assertIfInvalid:], UICollectionView.m:8,265

  2. uses triple "arm64e-apple-ios17.3.0", which is not compatible with the target triple "arm64-apple-ios17.0.0". Enabling per-module Swift scratch context.

Same problem I have, one way is to make default time zone for calendar, crash is gone but do not know if it's correct way, as all users will have one time zone.

class XYZFSCalendar: FSCalendar {
override init(frame: CGRect) {
super.init(frame: frame)
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)

   if let projectTimeZone = TimeZone(identifier: "UTC") {
      self.setValue(projectTimeZone, forKey: "timeZone")
      self.perform(Selector(("invalidateDateTools")))
   }

}
}

Same problem I have, one way is to make default time zone for calendar, crash is gone but do not know if it's correct way, as all users will have one time zone.

class XYZFSCalendar: FSCalendar { override init(frame: CGRect) { super.init(frame: frame) }

required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder)

   if let projectTimeZone = TimeZone(identifier: "UTC") {
      self.setValue(projectTimeZone, forKey: "timeZone")
      self.perform(Selector(("invalidateDateTools")))
   }

} }

Thanks, I tried this but it does not work in my case.
Even I downloaded the Fscalander demo App and it also crashed with the same case.

  1. Versions above 17 with TimeZone Mazatlan, Mexico.
  2. On Tap FsCalanderScope Example - It crash

I am not sure why it happens only on this timezone and OS 17, please give any solution if you have.

New PR is created for #1425
you can test the changes on your project as is one line of code