Xcode crashes when resuming a SwiftUI Preview

FB8970504

Our app is large and uses lots of cocoa pods. We have begun to incorporate SwiftUI in our app but the process has been very slow because SwiftUI previews immediately crash Xcode.

Here are the steps to reproduce:
  1. Open our project

  2. File -> New File -> SwiftUIView -> click Next -> click Create

  3. Do not make any changes to the SwiftUI view and click the “Resume” button on the canvas next to "Automatic preview updating paused"

The crash looks like this:
Code Block
Process: Xcode [42548]
Path: /Volumes/VOLUME/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 12.1 (17222)
Build Info: IDEFrameworks-17222000000000000~2 (12A7403)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [42548]
User ID: 501
Date/Time: 2021-01-14 11:33:36.900 -0600
OS Version: macOS 11.1 (20C69)
Report Version: 12
Bridge OS Version: 5.1 (18P3030)
Anonymous UUID: 08A4D22A-CFF4-170F-AAAD-9005B37F6F0E
Sleep/Wake UUID: 603546BE-7E90-4121-914C-000F6D6EE9B9
Time Awake Since Boot: 91000 seconds
Time Since Wake: 84000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007ffeea3c4ff0
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [42548]
VM Regions Near 0x7ffeea3c4ff0:
MALLOC_TINY 7fe701000000-7fe701100000 [ 1024K] rw-/rwx SM=PRV
--> STACK GUARD 7ffee6bc5000-7ffeea3c5000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0
Stack 7ffeea3c5000-7ffeeabc5000 [ 8192K] rw-/rwx SM=ALI thread 0
Application Specific Information:
ProductBuildVersion: 12A7403
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.CoreFoundation 0x00007fff203a5bc6 CFStringCompareWithOptionsAndLocale + 26
1 com.apple.Foundation 0x00007fff2113f170 -[NSString compare:options:range:] + 34
2 com.apple.dt.DVTFoundation 0x00000001050ce5ad DVTFindValueAssignmentForMacro(DVTMacroValueAssignmentMapTable&, NSString*, unsigned int) + 173
3 com.apple.dt.DVTFoundation 0x0000000105286376 -[DVTMacroExpansionScope(MRR) lookupValueForMacroName:hash:withCursor:] + 561
4 com.apple.dt.DVTFoundation 0x00000001052ad54c -[DVTMacroExpansionString_Substitution dvt_evaluateAsStringInScope:withState:] + 718
5 com.apple.dt.DVTFoundation 0x00000001052ad5cb -[DVTMacroExpansionString_Substitution dvt_evaluateAsStringInScope:withState:] + 845
6 com.apple.dt.DVTFoundation 0x0000000105286bfd -[DVTMacroExpansionScope(MRR) evaluatedStringValueForMacroNamed:returningFallbackConditionsUsed:] + 188
7 com.apple.Xcode.DevToolsCore 0x0000000129c7dfc2 -[PBXTarget evaluatedStringValueForBuildSetting:forBuildParameters:] + 129
8 com.apple.Xcode.DevToolsCore 0x0000000129e7d40b -[Xcode3Target evaluatedStringValueForBuildSetting:withBuildParameters:] + 207
9 com.apple.dt.UVKit 0x0000000159736da0 XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 576
10 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
11 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
12 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
13 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
14 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
15 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
... repeating ...
500 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
501 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
502 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
503 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
504 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
505 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
506 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
507 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
508 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
509 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
510 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940
511 com.apple.dt.UVKit 0x0000000159736f0c XcodeWorkspaceBuilder.recursivelyBuildNode<A>(from:with:into:) + 940

Sorry to hear you are having problems getting previews working. Best next step will be to file a feedback with the crash log and a sysdiagnose. Please report back here with the feedback ID and I'll make sure it gets to the right team as soon as possible!

The Feedback ID is FB8970504. It has the crash log, a sysdiagnose, and a very uninteresting screen recording of the issue being reproduced.
Xcode crashes when resuming a SwiftUI Preview
 
 
Q