Xcode 13.1 unstable, keeps crashing

Xcode 13.1 keeps crashing. All I do is click on a file and it crashes. Some files open fine, but if I click on particular files XCode will crash %100 of the time. There is nothing special about the files, just plain swift files ~300 lines. This is making Xcode 13.1 unusable

See crash log below.

Details: 2019 MacBook Pro 16", Big Sur, 64GB ram

Here my is a history of Xcode 13

  1. Uninstalled Xcode 12 using Parallels uninstaller app
  2. Installed Xcode 13
  3. Xcode crashes on opening files, tried several rounds of uninstalling & installing.
  4. Reformated HD and did fresh install of Big Sur.
  5. Installed Xcode 13
  6. Same thing, Xcode crashes on opening files.
  7. Gave up, started using AppCode w/out any issues
  8. Uninstalled Xcode 13 using Parallels uninstaller app
  9. Installed Xcode 13.1rc
  10. Same thing, Xcode crashes opening files.
  11. Went back to AppCode
  12. Tried Xcode again (not a reinstall, just ran it again) and it worked without any crashes.
  13. Used Xcode 13.1rc without any issues for about 5 days.
  14. Suddenly Xcode started crashing when opening files. (no changes to system or code)
  15. Uninstalled Xcode 13.1rc with Parallels uninstaller
  16. Installed Xcode 13.1
  17. Same issues, crashes consistently :(

Anyone have any workarounds?

Crash Log

Process:               Xcode [1934]
Path:                  /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:            com.apple.dt.Xcode
Version:               13.1 (19466)
Build Info:            IDEFrameworks-19466000000000000~20 (13A1030d)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Xcode [1934]
User ID:               501

Date/Time:             2021-10-28 10:50:36.620 -0700
OS Version:            macOS 11.6 (20G165)
Report Version:        12
Bridge OS Version:     5.5 (18P4759a)
Anonymous UUID:        0DFE01C0-3603-9A46-AC40-7F64E7D702E0

Time Awake Since Boot: 730 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Illegal instruction: 4
Termination Reason:    Namespace SIGNAL, Code 0x4
Terminating Process:   exc handler [1934]

Application Specific Information:
ProductBuildVersion: 13A1030d
Crashing on exception: -[__NSCFString substringWithRange:]: Range {16527, 6} out of bounds; string length 5512

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff205a71db __exceptionPreprocess + 242
1   DVTFoundation                       0x0000000101ac7fdd DVTFailureHintExceptionPreprocessor + 446
2   libobjc.A.dylib                     0x00007fff202e0d92 objc_exception_throw + 48
3   CoreFoundation                      0x00007fff2065de0a _CFThrowFormattedException + 202
4   CoreFoundation                      0x00007fff2051bce0 -[NSConstantDictionary objectForKey:] + 0
5   SourceModel                         0x000000013980e854 -[SMSourceModel nameOfItem:nameRanges:scopeRange:] + 934
6   SymbolCacheSupport                  0x0000000139c3096b $s18SymbolCacheSupport0A5TableC7element3for2inAC7ElementVSgSo17SMSourceModelItemC_So0iJ0CtF + 107
7   SymbolCacheSupport                  0x0000000139b9dda1 

...

I have only questions at this stage; you should try to investigate in that order:

  • Does it occur on several files ? What type of files ? .swift files ? .strings file ?
  • Do you succeed opening the file in Finder with a plain text editor ? Do you notice anything special ? I read in the crash log:

Crashing on exception: -[__NSCFString substringWithRange:]: Range {16527, 6} out of bounds; string length 5512

  • Do you see a string that may be that long (5512) ? Maybe you have an unbalanced opening quote in the file ?
  • Did you do a Clean Build Folder ?
  • Close Xcode, then double click on a file that causes crash directly in Finder ; that should open an Xcode window. Does it crash ? If not, that means it may be a problem of dependency between symbols in the whole project.
  • Did you try to open in an older version (Xcode 13.0 or 12.5 for instance)
  • Did you try the last release (13.2 ß)
  • Does the problem occur only when storyboard is open ? if so, you could try to open only storyboard and remove all the links to IBOutlets in the file that crashes
  • Could you attach one such file here for inspection ?

I have the same problem. On Xcode 13.0 and 13.1 both.

Also in a swift file containing a reducer for TCA.

It happens with me as well when I try to consume some functionalities from a 3rd party library. I'll try updating such lib

Edit: yeah lib updated and same crash

Edit(2): yeah also using TCA when touching the reducers goodies

Xcode 13.1 unstable, keeps crashing
 
 
Q