[SwiftUI Preview] App crashes when previewing on physical device but runs normally

Hello everyone, I've encountered an issue with SwiftUI Preview and would appreciate your help.

Problem Description In a mixed Objective-C and Swift project, I'm experiencing the following situation with SwiftUI Preview:

Crashes when previewing on a physical device The same code runs normally when launched directly through Xcode Project uses CocoaPods for dependency management with static frameworks

Project Environment:
Project Type: Mixed (Objective-C + Swift)
Dependency Management: CocoaPods
Dependency Type: Static frameworks
Device: Physical device preview

Steps to Reproduce:
Write Preview code in SwiftUI file Select physical device as Preview device Click Preview button Application crashes

I wanted to upload the "previews-diagnostics-20241212-104153.zip" file but found that I couldn't upload it using the AddFile button, so I uploaded it to GitHub instead.

https://github.com/wolfcolony/crash_report/blob/main/previews-diagnostics-20241212-104153.zip

Hi,

Sorry to hear you are having problems getting previews working on your device. This error can often indicate a crash in your application when it launches.

The best next step will be to file a feedback with diagnostics so we can take a look.

We will need the diagnostics Xcode Previews generates in order to make sure we understand the error the previews system is encountering.

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).

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

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 but you still want to provide diagnostics you can get the same diagnostics window by going under the Editor menu in the menu bar, then selecting 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

@wolfcolony thanks for doing your best to get us the diagnostics! So, looking at the error it's pretty weird.

BSActionErrorDomain (1):
==BSErrorCodeDescription: response-not-possible

==================================

|  MessageSendFailure: Message send failure for <ServiceMessage 21: update>

It's not obvious what's going on but we have a hunch. I see from the diagnostics that you're using the Xcode 16.1 tools. We just released Xcode 16.2 as well as macOS 15.2. There's a bunch of fixes that went in there including one that may affect you. If you use the -ObjC or -all_load linker flags in your project (which you might do since CocoaPods often leverage that) then definitely try out these new versions and let us know.

[SwiftUI Preview] App crashes when previewing on physical device but runs normally
 
 
Q