Hi, I have an issue with app preview

I can't seem to access preview for any of my views in any of my swift projects at all (using Mac to code and using iPhone 16 pro as preview and simulation, simulation can work), even after restarting Mac and Xcode itself. The preview section has a popup saying "Cannot preview in this file, unexpected error occured" (for every file), please tell me what is wrong and help me solve it to see the preview, thank you!

== PREVIEW UPDATE ERROR:

    XPCError
    
    XPCError: XPCError(kind: PreviewsServices.XPCError.Kind.connectionInterrupted)



== PREVIEW UPDATE ERROR:

    XPCError
    
    XPCError: XPCError(kind: PreviewsServices.XPCError.Kind.connectionInterrupted)



== VERSION INFO:

    Tools: 16B40
    OS:    23F79
    PID:   79705
    Model: MacBook Air
    Arch:  arm64e



== ENVIRONMENT:

    openFiles = [
        /Users/tkrobot/Documents/SolarSurvival/SolarSurvival/StartPage.swift
    ]
    wantsNewBuildSystem = true
    newBuildSystemAvailable = true
    activeScheme = SolarSurvival
    activeRunDestination = iPhone 16 Pro variant iphonesimulator arm64
    workspaceArena = [x]
    buildArena = [x]
    buildableEntries = [
        SolarSurvival.app
    ]
    runMode = JIT Executor



== SELECTED RUN DESTINATION:

    Simulator - iOS 18.1 | iphonesimulator | arm64 | iPhone 16 Pro | no proxy



== EXECUTION MODE OVERRIDES:

    Workspace JIT mode user setting: true
    Falling back to Dynamic Replacement: false



== PACKAGE RESOLUTION ERRORS:

    



== REFERENCED SOURCE PACKAGES:

    
    



== JIT LINKAGE:

    Run Destination: 445DD4D4-F429-4EAF-ABD1-70CB9873FFC6-iphonesimulator18.1-arm64-iphonesimulator
    JIT Link Description {
        7:SolarSurvival.app
    }
    



== SESSION GROUP 7195:

    workspace identifier: WorkspaceIdentifier(identifier: 15E7655C-6B5B-45CA-8470-F6AE38B59257)
    providers: [
        Preview Provider | Registry-StartPage.swift#1[preview] [Editor(7038)]
    ]
    translation units: [
        /Users/tkrobot/Documents/SolarSurvival/SolarSurvival/StartPage.swift
    ]
    attributes: [
        Editor(7038):     []
    ]
    session: 7200
    request sessions: [
        Registry[Registry-StartPage.swift#1[preview] (line 125)]: not completed
    ]



== UPDATE SESSION 7200:

    Start Date: Monday, 18 November 2024 at 3:46:11 PM Singapore Standard Time
    Preview Preflight {
        UpdaterStore {
            updaterLimit: single
            expectedAbandonedIdentifiers: [5781, 7213]
        }
        Simulator {
            platform: iphonesimulator
            device: 7BDABCB3-11B2-47C1-9A63-183A01E53B67 iPhone 16 Pro
            buildNumber: 22B81
            runtimePath: /Library/Developer/CoreSimulator/Volumes/iOS_22B81/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.1.simruntime
        }
        host bundle: 
        BryanNguyen.SolarSurvival {
            url: file:///Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator/SolarSurvival.app
            version: 7205
            signingInformation: 
            Code Signing {
                identifier: BryanNguyen.SolarSurvival
                hasGetTaskAllow: false
                isSandboxed: false
            }
            attributes: [
                AgentCompanionAppBundleIdentifierKey: nil,
                LaunchConfigEnvironmentVariablesPreviewAttributesKey: ["PACKAGE_RESOURCE_BUNDLE_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "OS_ACTIVITY_TOOLS_PRIVACY": "YES", "SQLITE_ENABLE_THREAD_ASSERTIONS": "1", "TERM": "dumb", "DYLD_LIBRARY_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "OS_LOG_DT_HOOK_MODE": "0x07", "CFLOG_FORCE_DISABLE_STDERR": "1", "DYLD_INSERT_LIBRARIES": "/Library/Developer/CoreSimulator/Volumes/iOS_22B81/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.1.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libLogRedirect.dylib", "OS_LOG_TRANSLATE_PRINT_MODE": "0x80", "__XCODE_BUILT_PRODUCTS_DIR_PATHS": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "__XPC_DYLD_FRAMEWORK_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "IDE_DISABLED_OS_ACTIVITY_DT_MODE": "1", "DYLD_FRAMEWORK_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "__XPC_DYLD_LIBRARY_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "OS_ACTIVITY_TOOLS_OVERSIZE": "YES", "OS_LOG_DT_HOOK_PREFIX": "OSLOG-B9671B16-DDE7-4DCE-880C-E6EA1F0D8763"],
                AppExtensionIdentifierPreviewAttributeKey: nil,
                LaunchConfigArgumentsPreviewAttributesKey: [],
                AgentRoleKey: Previews,
                AgentRunModeKey: JIT Executor,
            ]
        }
        builtTargetDescriptions: Build Logs/ResolvedBuiltTargetDescriptions-request-1-BryanNguyen.SolarSurvival.txt
    }
    Preview Provider {
        UpdaterStore {
            updaterLimit: single
            expectedAbandonedIdentifiers: [5781, 7213]
        }
        Simulator {
            platform: iphonesimulator
            device: 7BDABCB3-11B2-47C1-9A63-183A01E53B67 iPhone 16 Pro
            buildNumber: 22B81
            runtimePath: /Library/Developer/CoreSimulator/Volumes/iOS_22B81/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.1.simruntime
        }
        host bundle: 
        BryanNguyen.SolarSurvival {
            url: file:///Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator/SolarSurvival.app
            version: 7205
            signingInformation: 
            Code Signing {
                identifier: BryanNguyen.SolarSurvival
                hasGetTaskAllow: false
                isSandboxed: false
            }
            attributes: [
                AgentCompanionAppBundleIdentifierKey: nil,
                LaunchConfigEnvironmentVariablesPreviewAttributesKey: ["PACKAGE_RESOURCE_BUNDLE_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "OS_ACTIVITY_TOOLS_PRIVACY": "YES", "SQLITE_ENABLE_THREAD_ASSERTIONS": "1", "TERM": "dumb", "DYLD_LIBRARY_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "OS_LOG_DT_HOOK_MODE": "0x07", "CFLOG_FORCE_DISABLE_STDERR": "1", "DYLD_INSERT_LIBRARIES": "/Library/Developer/CoreSimulator/Volumes/iOS_22B81/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.1.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libLogRedirect.dylib", "OS_LOG_TRANSLATE_PRINT_MODE": "0x80", "__XCODE_BUILT_PRODUCTS_DIR_PATHS": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "__XPC_DYLD_FRAMEWORK_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "IDE_DISABLED_OS_ACTIVITY_DT_MODE": "1", "DYLD_FRAMEWORK_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "__XPC_DYLD_LIBRARY_PATH": "/Users/tkrobot/Library/Developer/Xcode/DerivedData/SolarSurvival-gcsnjdzgmyvjpoetkylvchakcvfc/Build/Products/Debug-iphonesimulator", "OS_ACTIVITY_TOOLS_OVERSIZE": "YES", "OS_LOG_DT_HOOK_PREFIX": "OSLOG-B9671B16-DDE7-4DCE-880C-E6EA1F0D8763"],
                AppExtensionIdentifierPreviewAttributeKey: nil,
                LaunchConfigArgumentsPreviewAttributesKey: [],
                AgentRoleKey: Previews,
                AgentRunModeKey: JIT Executor,
            ]
        }
        builtTargetDescriptions: Build Logs/ResolvedBuiltTargetDescriptions-request-2-BryanNguyen.SolarSurvival.txt
    }
    Build Graph {
        SolarSurvival.app (#7)
           SDWebImageSwiftUI (#4)
              SDWebImageSwiftUI (#3)
                 SDWebImage (#2)
                    SDWebImage (#1)
           sourceFile(file:///Users/tkrobot/Documents/SolarSurvival/SolarSurvival/StartPage.swift -> StartPage.swift) (#5)
           StartPage.swift (#6)
    }
    Update Plan {
        iOS [arm64 iphonesimulator18.1 iphonesimulator] (iPhone 16 Pro, 445DD4D4-F429-4EAF-ABD1-70CB9873FFC6-iphonesimulator18.1-arm64-iphonesimulator), [], thinning disabled, thunking enabled) {
            Destination: iPhone 16 Pro 445DD4D4-F429-4EAF-ABD1-70CB9873FFC6 | default device for iphonesimulator [
                SolarSurvival app - Previews {
                    execution point packs [
                        [source: StartPage.swift, role: Previews] (in SolarSurvival)
                    ]
                    translation units [
                        StartPage.swift (in SolarSurvival.app)
                    ]
                    modules [
                        SDWebImage
                        SDWebImage
                        SDWebImageSwiftUI
                        SDWebImageSwiftUI
                        SolarSurvival.app
                    ]
                    jit link description [
                        SolarSurvival.app
                    ]
                }
            ]
        }
    }

Hi,

Sorry to hear you are having problems getting previews working. This error can often indicate a crash in your application when it launches, or a problem with the simulator. If you look into the folder ~/Library/Logs/DiagnosticReports, do you see any crash reports for your app or for anything where the timestamps line up with your attempt to use previews?

If not, 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
Hi, I have an issue with app preview
 
 
Q