Xcode Preview says:Cannot preview in this file: Failed to launch (App Name)

When I attempt to preview my code, I encounter an error message stating, “Cannot preview in this file: Failed to launch (App Name).” This issue is specific to this particular app. I attempted creating a new project, and that works fine.

This is what it says in the diagnostics:

|  [Remote] JITError
|  
|  ==================================
|  
|  |  [Remote] LLVMError
|  |  
|  |  LLVMError: LLVMError(description: "The file was not recognized as a valid object file")

Hi,

Sorry to hear you are having problems getting previews working. This error looks like one that was fixed in Xcode 16 seed 4. Could you double check that you are using the latest available seed version?

If you are still seeing this we would love you to file a feedback with diagnostics so we can take a look.

Steps to generate helpful diagnostics:

  1. Download and install the logging profile on all devices involved. Instructions and profiles are available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift
  2. Reproduce the issue
  3. Click the "Diagnostics" button in the error banner in Previews' Canvas area (or if the banner is missing you can use the menu: Editor > Canvas > Diagnostics)
  4. In the sheet that appears, click "Generate Report" in the bottom left of the sheet
  5. Attach (or make from the folder) the resulting zip file to the bug report (will be named something like previews-diagnostics-0123456789.zip)
  6. Generate the sysdiagnose(s) and attach those too

I updated Xcode beta to the latest version, that didn't work. It won't let me attach a ZIP file so here is an iCloud link: https://www.icloud.com/iclouddrive/068eoMNlp49VaF1muumoaG2Lg#Diagnostics

Got the same issue in Xcode 16 Seed 5 (16A5221g)

Filed feedback with diagnostic information as FB14728865

I realized that if I delete all code except for one Preview, it still does not work. If I then remove all SPM dependencies, the Preview works. It doesn't work if there's even one dependency, no matter which one. Hope that helps in finding the issue.

I am experiencing the same issue on RC1 as well. If anyone has found a workaround, I'd appreciate any tips!

Yup still experiencing the same issue with RC1. Anyone have a workaround?

Experiencing this as well on Version 16.0 (16A242d). Does anybody has found a solution?

Still experiencing this as well on Version 16.0 (16A242d).

Try enabling "Previews Legacy" support, with the canvas opened go to Editor > Canvas > Use Legacy Previews Execution.

That fixed me the same issue, hope it works for you.

i also have the same error in Xcode Version 16.0 (16A242d).

Xcode Preview says:Cannot preview in this file: Failed to launch (App Name)
 
 
Q