Failed to run on device

tutorial hello world
simulation success but failed on device
xcode 12.1
iphone12 ios 14.1

Diagnostics below:

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/2048E5CE-8AFF-4868-A9A3-E244714ABF45//tmp/F32DDE22-452E-4F37-AD3F-34A26AE9688D-ContentView.2.preview-thunk.dylib": Optional(dlopen(/private/var/mobile/Containers/Data/Application/2048E5CE-8AFF-4868-A9A3-E244714ABF45/tmp/F32DDE22-452E-4F37-AD3F-34A26AE9688D-ContentView.2.preview-thunk.dylib, 2): no suitable image found. Did find:
|  /private/var/mobile/Containers/Data/Application/2048E5CE-8AFF-4868-A9A3-E244714ABF45/tmp/F32DDE22-452E-4F37-AD3F-34A26AE9688D-ContentView.2.preview-thunk.dylib: code signature invalid for '/private/var/mobile/Containers/Data/Application/2048E5CE-8AFF-4868-A9A3-E244714ABF45/tmp/F32DDE22-452E-4F37-AD3F-34A26AE9688D-ContentView.2.preview-thunk.dylib'
| )

Code:

import SwiftUI

struct ContentView: View {
  var body: some View {
    Text("Hello, world!")
      .padding()
  }
}

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}

so frustrated
Did you try with Xcode 12.2 beta ?

Have a look here: https ://filipmolcik com/xcode-cannot-preview-in-this-file-update-failed/
It seems they have solved a very similar problem.

Solution
Close Xcode
Delete Build and DerivedData folders in your project path
Restart your mac
Build your project with the  button
In case you don’t see the preview click Editor -> Canvas.


Sorry to hear you are having problems getting previews working. It's worth giving Claude31's suggestions a try, but 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)

If you then report back here with the feedback ID I'll make sure it gets to the right team as soon as possible.
same problem here with the same error character for character.
using iphone 11 ios 14.2
and an 2018 macbook pro running mac big sur 11.0.1 (20B50)
and xcode 12.2
been like this for months.
Having the same problem with Xcode 12.4 (12D4e) and iPad Pro 4th Gen. iOS 14.3 with all my projects including the files provided by a Apple SwiftUI Tutorial (https://developer.apple.com/tutorials/swiftui/handling-user-input). I would appreciate help a lot
Same problem with me: Xcode 12.4 (12D4e), iPhone 11, iMac 11.2.1 (20D74). Would also appreciate your help, thanks.
try removing ContentView_Previews and clear you code build using Command+Shift+K
some errors seems stupid, and needs stupid solving methods!
Same problem. Xcode 12.4 (12D4e). iPad Pro 10.5. Cleaning DerivedData not solves.

Feedback report FB9028409 created

Would also appreciate your help, thanks.
I reported a bug to apple with the following feedback ID: FB9037331.
Failed to run on device
 
 
Q