Post

Replies

Boosts

Views

Activity

Reply to Crash in iOS18
I am getting the same crash but my use case shouldn't be triggering the crash by Apple's description. In my case, I have a custom function to dynamically calculate cell sizes defined as: public func intrinsicCellSize( forCellAtIndexPath indexPath: IndexPath, width: CGFloat? = nil, height: CGFloat? = nil ) -> CGSize { guard let dataSource = dataSource else { return .zero } let cell = dataSource.collectionView(self, cellForItemAt: indexPath) if let cell = cell as? HeightProvidingCell, let width { return .init(width: width, height: cell.provideHeight(for: width)) } let targetSize = CGSize( width: width ?? UIView.layoutFittingExpandedSize.width, height: height ?? UIView.layoutFittingExpandedSize.height ) let size = cell.contentView.systemLayoutSizeFitting( targetSize, withHorizontalFittingPriority: .fittingSizeLevel, verticalFittingPriority: .fittingSizeLevel ) return size } I call this in the sizeForItemAt delegate function. This was working flawlessly before updating macOS and Xcode but now this crashes. Specifically, it crashes with the call let cell = dataSource.collectionView(self, cellForItemAt: indexPath) By Apple's error message, this should be fine as I'm not calling deque, the error message even suggests that you use this method. Perhaps the issue is the order in which UIKit calls the delegate and dataSource methods. By adding print statements, I discovered that sizeForItemAt is called before cellForItemAt so in my case, the flow of function calls is: sizeForItemAt (Called by UIKit) cellForItemAt (Called by me) cellForItemAt (Called by UIKit) Perhaps UIKit is expecting the first call of cellForItemAt to be made by UIKit and not the user. If this is the case, my app is broken since I relied heavily on this
2w