Summary
I'm facing a severe issue in an Xcode project at work and would be grateful for any advice, hints or comments on how to further narrow down or solve this problem!
Since a week or two, our project crashes while debugging (on simulator and device) at random places where Swift classes are initialised or their types are used.
Examples
Here is an example how it looks:
- The table view fails to recognize the ListSectionHeader's inheritance
- When printing it's type, a different class is returned
- The returned class of the
.self
is always an Objective-C class of our Core.framework
Another example, where a super.init
call fails, because the debugger suddenly confuses the parent class to be of a different type:
- Sometimes it crashes directly, when a Swift class is initialised with a
BAD_EXEC_ACCESS
What we've tried
Things we have noticed and tried so far:
- The crash disappears on release builds
- The issue disappears with enabled memory or thread sanitisers
- The issue happens on Xcode 12.4, 12.5.1 and Xcode 13.0
- We enabled "SWIFT_COMPILATION_MODE = wholemodule" which made the issue disappear for a while, but it has returned after more Swift code has been added to the project
- If we add or remove Swift code, the crash moves to a different class, as if a mapping table (??) of class names and types is moved (pure speculation here)
- So far I'm unable to reproduce the issue in a sample project
Additional Infos
A few things about our project:
- Xcode workspace with a few static frameworks
- Core-Framework with the majority of being Objective-C classes
- A UserInterface-Framework that is Swift-only and imports the Core-Module in many classes
- All of our frameworks are part of an umbrella framework that is integrated in a test application that we use for debugging
Ending thoughts
I have my suspicions, that we may accidentally trigger some kind of compiler optimisation bug, that has to do with our mixed Swift and Objective-C code base.
If anybody has any idea on how to narrow down this crash, or has seen these symptoms, I would be very grateful. Right now it prevents us from any development.
CodePudding user response:
We haven't been able to identify the root cause of the issue, but we managed to avoid the crash/bug when we disabled our test plan in our app's scheme. We noticed this, when we created a new app target and everything worked. After re-configuring the target and scheme, the issue reappeared as soon as the UI-test plan was added.
Perhaps this strategy helps anyone with a similar problem.