SwiftUI Preview crash in Xcode 27 / iOS 27 simulator — segfault in libobjc map_images inside XCPreviewAgent's JIT-compiled preview binary (works with "Use Legacy Preview Execution")

Environment:

  • Xcode 27 (macOS 27.0, build 26A428)

  • iOS 27.0 simulator (build 24A434), tested on iPhone 18 Pro

  • CoreSimulator 1174.9.2

  • Large app target: dozens of linked frameworks (first-party SPM modules plus several third-party SDKs)

  • it occurred on xcode 26 also

Description:

SwiftUI canvas previews consistently crash XCPreviewAgent with EXC_BAD_ACCESS / SIGSEGV when rendering previews for a fairly large app target, across multiple different SwiftUI views (not tied to one specific file's code).

Workaround found: the crash does not occur when "Use Legacy Preview Execution" is enabled (Xcode's preview settings). With the default (non-legacy, JIT-based) preview execution path, it crashes reliably; switching to legacy execution, previews render normally.

Possible contributing factor — project size / timing: we suspect the size of the project may also be a factor, independent of the crash itself. The new (non-legacy) execution path recompiles/JITs the app for the canvas on every preview, and for a target this large that process takes noticeably longer than it does under legacy execution. It's plausible that on top of the crash described below, the new path is also more prone to timing out or failing under load on larger projects, simply because there's more to JIT-compile and load within whatever time budget the preview agent allows. We can't fully separate "crashes because of X" from "runs out of time because of project size" from the crash logs alone, but both seem worth flagging since they may share the same root cause in the new execution path's handling of larger binaries.

Crash signature #1 (default preview execution, first attempts): Crashing Thread: 0 libswiftCore.dylib swift_conformsToProtocolMaybeInstantiateSuperclasses(...) 1 libswiftCore.dylib swift_conformsToProtocolWithExecutionContext 2 libswiftCore.dylib swift::_conformsToProtocol(...) 3 libswiftCore.dylib swift::_checkGenericRequirements(...) Termination: SIGSEGV / Segmentation fault: 11

Crash signature #2 (default preview execution, after removing an unrelated third-party SDK dependency from the previewed module, to rule it out as a cause): Crashing Thread ("com.apple.xojit_executor.wrapper_functions"): 0 libobjc.A.dylib readClass(objc_class*, bool, bool) 1 libobjc.A.dylib map_images_nolock 2 libobjc.A.dylib map_images 3 libobjc.A.dylib _objc_map_images 4-7 <unsymbolicated / anonymous image, source="A" (Absent) in the crash report> Exception: EXC_BAD_ACCESS (SIGSEGV), KERN_INVALID_ADDRESS

In the second case, the crash log's usedImages list shows the frames above the objc runtime resolving to an image with no path, no resolvable UUID, and "source": "A" — this appears to be the dynamically JIT-compiled preview binary that XOJITExecutor builds and hot-loads for the canvas (rather than a normal on-disk framework), and the crash occurs while the Objective-C runtime is registering classes from it during _objc_map_images.

What we've ruled out:

  • Not caused by the specific SwiftUI view being previewed — reproduces across multiple unrelated views in the same target.
  • Not caused by a specific third-party SDK: we removed a heavyweight closed-source analytics SDK dependency from the previewed module entirely (confirmed via successful xcodebuild build with zero references left), and the crash still occurred with an equivalent signature under default preview execution.
  • Confirmed via symbolicated .ips crash reports in ~/Library/Logs/DiagnosticReports/XCPreviewAgent-*.ips that the crashing frames are inside Apple's own preview infrastructure (libobjc.A.dylib, libswiftCore.dylib, XOJITExecutor), not in application or third-party framework code.
  • Confirmed the failure is specific to the new (non-legacy) preview execution path: enabling "Use Legacy Preview Execution" eliminates the crash entirely, with no other changes.

Question for the community: Has anyone else seen SwiftUI Previews crash with a libobjc/map_images or swift_conformsToProtocol* segfault specifically on Xcode 27 / iOS 27 simulator with the new (non-legacy) preview execution path, for apps with a large number of linked frameworks? Does project size/build time make the new execution path more likely to fail or time out for anyone else? Is "Use Legacy Preview Execution" the recommended workaround until this is fixed, or should this be filed separately as Feedback?

Hi,

Sorry to hear you are having problems getting previews working. You've done some good debugging here, and we appreciated all the additional details. Unfortunately it is unlikely that we will make much progress on this without a project that we can use to reproduce. Would it be possible for you to file a feedback with one attached?

If not, then a feedback with a preview diagnostic will be the second best and maybe the additional diagnostics there will offer us more clues as to what is going wrong.

Install the logging profile using instructions available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift on your mac running Xcode, and on your physical preview device (if you are using one).

Then when you reproduce the problem in Xcode:

  1. Either (a) an error banner will appear, click the "Diagnostics" button in that banner; or (b) if you're not seeing an error you can get the same diagnostics window by going under the Editor menu in the menu bar, then the Canvas submenu, then selecting "Diagnostics".
  2. In the sheet that appears, click "Generate Report" in the bottom left of the sheet
  3. Attach (or make from the folder) the resulting zip file to the bug (will be named something like previews-diagnostics-0123456789.zip)
  4. Generate a sysdiagnose on your mac and any on-device preview devices, and attach those too
SwiftUI Preview crash in Xcode 27 / iOS 27 simulator — segfault in libobjc map_images inside XCPreviewAgent's JIT-compiled preview binary (works with "Use Legacy Preview Execution")
 
 
Q