Xcode Canvas preview connected to iPhone error

"Can not preview in this file"

Xcode 16.0 iPhone 14 Pro , iOS 18.0

When I choose to start Preview on my iPhone, the canvas screen keeps showing loading circle animation. The iPhone enters the Xcode Previews App but only displays the default screen (Xcode icon& 'Preview from Xcode')

I uploaded the some of diagnostics files

Hi,

Sorry to hear you are having problems getting previews working. Some of the output you included has this error listed com.apple.dt.deviceprep. It'd be interesting to know if you are just seeing issues with previews on-device, or if building+running the app (⌘R) on the device has problems too?

Though looking at the logs you included they make it look like you are attempting to do an in-canvas preview, at which point my previous question doesn't apply.

I think probably the best way to dig in to this further would be for you 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.

If you are having issues with Xcode, macOS, catalyst or on-device iOS previews then download and install the logging profile for your device. Instructions and profiles are available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift Attach the sysdiagnose to the radar as well as the diagnostics using the instructions below.

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 the sysdiagnose(s) and attach those too

The error, NSError.com.apple.dt.deviceprep.-10:, usually happens when Xcode is still doing work setting up the device. This shouldn't be directly related to Previews. Are you able to build and run targeting the same device?

Thank you!

According to your instructions, I recreated the scene: using canvas preview in Xcode 16.0, set to display on my iPhone.

At the same time, I also received two diagnostic files, but due to some strange restrictions on file uploads here, I had to share them with you via OneDrive: https://1drv.ms/f/s!ArbhaqRDUr_1hzoX4ieFho2GFy3F?e=Ws5h38

Thanks for those. I am seeing signs that the simulators on your system are having issues.

In the project if you select an iPhone Simulator as your run destination and you choose "build+run" (the play button in the app's title/tool bar) does the simulator launch and successfully run your app?

Could you also attempt running this command in Terminal.app xcrun simctl --set previews delete all. This will delete all your current preview's focused sims and allow your xcode to start with a clean slate, which may help in case something has gotten corrupted or in a bad state.

Thank you for your reply After testing, I was able to successfully run the built program in the simulator.

But after I successfully executed xcrun simctl --set previews delete all, the preview interface (simulate iPhone 16) kept spinning icon. Although there were no ongoing tasks in the status bar of the Xcode window (I mean, there were no signs or icons indicating something was being loaded), it still failed.

And when I selected my own phone as the Preview, the original issue still occurred.

Meanwhile, it seems that something crashed, followed by Xcode crashing about 2 minutes later. I received two error messages:

MobileCal Crash

-------------------------------------

Translated Report (Full Report Below)

-------------------------------------



Incident Identifier: A761F796-61A8-40B4-8F12-FA6C60BFF212

CrashReporter Key:   [REDACTED]

Hardware Model:      MacBookAir10,1

Process:             MobileCal [11571]

Path:                /Library/Developer/CoreSimulator/Volumes/iOS_22B5045f/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.1.simruntime/Contents/Resources/RuntimeRoot/Applications/MobileCal.app/MobileCal

Identifier:          com.apple.mobilecal

Version:             1.0 (1)

Code Type:           ARM-64 (Native)

Role:                Non UI

Parent Process:      launchd_sim [10911]

Coalition:           com.apple.CoreSimulator.SimDevice.0AA7C584-BFB6-44F5-96BB-2D02B7BADC64 [38990]

Responsible Process: SimulatorTrampoline [42568]



Date/Time:           2024-10-23 09:16:19.2551 +0800

Launch Time:         2024-10-23 09:15:46.6077 +0800

OS Version:          macOS 15.0 (24A335)

Release Type:        User

Report Version:      104



Exception Type:  EXC_CRASH (SIGKILL)

Exception Codes: 0x0000000000000000, 0x0000000000000000

Termination Reason: FRONTBOARD 2343432205 

<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-create watchdog transgression: app<com.apple.mobilecal((null))>:11571 exhausted real (wall clock) time allowance of 21.57 seconds

ProcessVisibility: Background

ProcessState: Running

WatchdogEvent: scene-create

WatchdogVisibility: Background

WatchdogCPUStatistics: (

"Elapsed total CPU time (seconds): 103.730 (user 40.930, system 62.800), 56% CPU",

"Elapsed application CPU time (seconds): 0.328, 0% CPU"

) reportType:CrashLog maxTerminationResistance:Interactive>



Triggered by Thread:  0



Kernel Triage:

VM - (arg = 0x0) Waiting on busy page was interrupted

Xcode Crash

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Xcode [10575]
Path:                  /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:            com.apple.dt.Xcode
Version:               16.0 (23051)
Build Info:            IDEApplication-23051000000000000~2 (16A242d)
App Item ID:           497799835
App External ID:       869020508
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2024-10-23 09:16:35.8507 +0800
OS Version:            macOS 15.0 (24A335)
Report Version:        12
Anonymous UUID:        [REDACTED]

Time Awake Since Boot: 91000 seconds

System Integrity Protection: enabled

Crashed Thread:        12

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x8000000000000010 -> 0x0000000000000010 (possible pointer authentication failure)
Exception Codes:       0x0000000000000001, 0x8000000000000010

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [10575]

VM Region Info: 0x10 is not in any region.  Bytes before following region: 4304338928
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      1008f0000-1008f4000    [   16K] r-x/r-x SM=COW  /Applications/Xcode.app/Contents/MacOS/Xcode

Ah, your project may be hitting a known issue trying to launch the app under preview in certain configurations. We made progress on this in the Xcode 16.1 beta. Are you able to test that out to see if this makes progress?

Xcode Canvas preview connected to iPhone error
 
 
Q