Error when previewing on device

When the Xcode Previews app opens on the device, this is the error message in Xcode: RemoteHumanReadableError: Failed to update preview. Error encountered when sending 'display' message to agent.

I tried cleaning the build folder and quitting then reopening Xcode to no avail.

Using Xcode 12.0.1 previewing on iPhone 11.
Answered by BabyJ in 686717022

I have tried this once more using Xcode 13 beta 5 using a device running iOS 15 beta 8 and it works.

Thank you very much to those who got this working!

Try downloading Xcode 12.2 Beta 2 here
This still doesn’t work with Xcode 12.2
Same error for me. I tried Xcode 12.2, Xcode 12.3 beta, doesn't work. My device is iPhone 12 pro max. iOS 14.3 beta 2.
== PREVIEW UPDATE ERROR:
Code Block
RemoteHumanReadableError: Failed to update preview.
Error encountered when sending 'display' message to agent.
==================================
| RemoteHumanReadableError
|
| LoadingError: failed to load library at path "/private/var/mobile/Containers/Data/Application/16712E81-3730-4827-A26F-A9AA2399EB0B//tmp/C791BCFF-36DF-4238-8C18-38E85FD6FEE0-ContentView.2.preview-thunk.dylib": Optional(dlopen(/private/var/mobile/Containers/Data/Application/16712E81-3730-4827-A26F-A9AA2399EB0B/tmp/C791BCFF-36DF-4238-8C18-38E85FD6FEE0-ContentView.2.preview-thunk.dylib, 2): no suitable image found. Did find:
| /private/var/mobile/Containers/Data/Application/16712E81-3730-4827-A26F-A9AA2399EB0B/tmp/C791BCFF-36DF-4238-8C18-38E85FD6FEE0-ContentView.2.preview-thunk.dylib: code signature invalid for '/private/var/mobile/Containers/Data/Application/16712E81-3730-4827-A26F-A9AA2399EB0B/tmp/C791BCFF-36DF-4238-8C18-38E85FD6FEE0-ContentView.2.preview-thunk.dylib'
| )
I have been also getting these errors. I thought I missed some step of configuration.
Same error for me
Xcode Version 12.2 (12B45b)
iPhone SE on iOS 14.1
Code Block
RemoteHumanReadableError: Failed to update preview.
Error encountered when sending 'display' message to agent.
==================================
|  RemoteHumanReadableError
|  
|  LoadingError: failed to load library at path "/private/var/mobile/Containers/Data/Application/66168AF1-A427-4DD2-BC79-C9B0BF1198DB//tmp/13AA5AC6-EB80-4560-980A-7DE8E77CE026-ContentView.2.preview-thunk.dylib": Optional(dlopen(/private/var/mobile/Containers/Data/Application/66168AF1-A427-4DD2-BC79-C9B0BF1198DB/tmp/13AA5AC6-EB80-4560-980A-7DE8E77CE026-ContentView.2.preview-thunk.dylib, 2): no suitable image found.  Did find:
|  /private/var/mobile/Containers/Data/Application/66168AF1-A427-4DD2-BC79-C9B0BF1198DB/tmp/13AA5AC6-EB80-4560-980A-7DE8E77CE026-ContentView.2.preview-thunk.dylib: code signature invalid for '/private/var/mobile/Containers/Data/Application/66168AF1-A427-4DD2-BC79-C9B0BF1198DB/tmp/13AA5AC6-EB80-4560-980A-7DE8E77CE026-ContentView.2.preview-thunk.dylib'
|  )


No changes in Xcode 12.3
Xcode 12.4 hasn’t changed this at all. Same message and no on-device preview. 😞
It might be a problem at my end but other people have been having issues so I don’t know what the problem is.
Sorry to hear you are having problems getting previews working. To start from a fresh slate you can use the terminal app and run xcrun simctl --set previews delete all.

If that still doesn't resolve issue then probably best next step will be to file a feedback with diagnostics.
We will need the diagnostics Xcode Previews generates in order to make sure we understand the error the previews system is encountering.
  1. When you get an error in Xcode Previews, an error banner appears in the canvas

  2. Click the "Diagnostics" button in that banner

  3. In the sheet that appears, click "Generate Report" in the bottom left of the sheet

  4. Attach (or make from the folder) the resulting zip file to the bug (will be named something like previews-diagnostics-0123456789.zip)

Unfortunately, running that command still resulted in the same error message.
I did file a feedback report (FB8991275) so hopefully this should be resolved soon.
Thanks for your help Frameworks Engineer.
I also filed a feedback report. Though, now answer yet (FB9037331). There are numerous questions with the same error but still none of them with a helpful answer.

I completely reinstalled macOS, Xcode and so on. Tested on two different macbooks, two different devices, and signed with two different accounts. No chance. Even tried with Project Files provided by Apple (SwiftUI tutorial). Nothing, absolutely nothing helped
I don’t know if I’m sad or just frustrated but Xcode 12.5 has not resolved this either, at least not for me anyway, throwing the same error as last time.

The feedback that I submitted previously has less than ten recent similar reports, but Apple hasn’t responded to it.
I guess at this point, we’d be waiting for on-device previews to work in Xcode 13.

Hi,

Sorry in the delay in getting back to you. I've made sure both your feedback reports have been assigned to the right team so they can get triaged as soon as possible.

I’ve tried again with Xcode 13 beta 2 previewing on a device with iOS 15 beta 2 and the same error appears in the preview canvas.

Hopefully, this will be resolved in time for the final release.

After seeing that my feedback report (FB8991275) has a potential fix in Xcode 13, I tried previewing on a device running iOS 15 beta 4 using Xcode 13 beta 4 and unfortunately I am getting the same error message, again. I really hope that this fix will be available in future betas or at least the official release of Xcode 13.

Accepted Answer

I have tried this once more using Xcode 13 beta 5 using a device running iOS 15 beta 8 and it works.

Thank you very much to those who got this working!

Error when previewing on device
 
 
Q