I have had this bug in my project for a long time and I just can't figure it out. It is a SpriteKit application and I'm using RxSwift to coordinate game events.
The problem is the error is thrown at the very top level of the application (
@main), and the array isn't identified by name. I've used the debugging tools to examine all the threads. The few that are in "my code" (as opposed to just assembly) are always in a different spots and almost never in any sort of array operation. I've used LLDB to interrogate the application as much as possible, but since in the thread with the error there is only a memory address to go on, it hasn't helped much. (I can print out the contents of that address but as you can imagine it isn't very illuminating since I don't even know the type of the contents.)
I haven't been able to find any part that of the application that triggers this error. I've carefully examined all interactions with collections and ensured no concurrency issues or attempts to change the contents. I even migrated from using NSLocks to the new actor concurrency model in swift to protect access to all collections. It works either way, but the error is the same:
Thread 1: "*** Collection <__NSArrayM: 0x6000006a9a70> was mutated while being enumerated."
I realize since I can't provide an isolated code block where this is happening it is difficult to help, but I'm hoping for guidance on how I can narrow it down. I've probably spend 40 hours on it so far. It has forced me to learn LLDB, the internal debugging tools in Xcode, and the structured concurrency system in Swift - so nice journey but I'm still left with this issue.