My Existing TableViewController is crashing on Xcode 11 beta1

I have faced the same issue when providing support for iOS 13.

This is a new exception in iOS 13 that UITableView will raise in order to prevent and proactively alert you of a situation that would previously cause undefined behaviour and a variety of strange, seemingly unrelated, and hard-to-debug issues (including crashes).

What is happening here is that UITableView is in the middle of asking its dataSource to return a cell for each visible row and is configuring the properties of the returned cells so they can be displayed. And in the middle of this updating -- most likely inside a callback from the table view itself about a specific row such as tableView(_:cellForRowAt:) tableView(_:canEditRowAt:), etc -- your code is asking the table view to return the visible cells. This is obviously problematic, because UITableView is right in the middle of preparing those cells, so it cannot possibly return a meaningful answer.

The fix for this is to look at where you are calling visibleCells in the backtrace when this exception is raised, and then do one of two things:

Option 1:

Move the usage of visibleCells to a better place, so that you aren't asking for the visibleCells from someplace that is called during the process of creating/configuring/updating those same cells. A great place to ask for the visible cells is after the table view lays out, so for example if the table view is the view of a view controller you can use viewDidLayoutSubviews(), or in a subclass of UITableView do it after calling super.layoutSubviews().

Option 2:

Depending on what you're actually trying to do, you might be able to skip using visible cells altogether. For example, you might be able to leverage the callbacks tableView(_:willDisplay:forRowAt:) and tableView(_:didEndDisplaying:forRowAt:) to track when cells are visible instead.

If you are hitting this exception and you think you are requesting the visible cells from a location that should be valid/allowed, please share the backtrace when you hit this exception and details about what you're trying to do.

Update:

I am sure but plateNoPrefix.becomeFirstResponder() causing the crash. As of now, you can check by pasting this code in viewDidAppear method

OR

Execute this code after delay (Worked for me)

 DispatchQueue.main.asyncAfter(deadline: .now()+0.1) {
      // Your code
 }

For details clerification you can refer Apple Developer Forum


This is a new exception in iOS 13 that UITableView will raise in order to prevent and proactively alert you of a situation that would previously cause undefined behavior and a variety of strange, seemingly unrelated, and hard-to-debug issues

Please have a look at Apple Developer Forum