Xcode preview fails

I recieve the error message "XOJITError: Could not create code file directory for session: Permission denied". I'm Using Xcode 16.2. It is an AppKit project using SwiftUI and it also happens if I create a clean project. Error log is attached.

== DATE:

    Wednesday, 18 December 2024 at 23.09.08 Central European Standard Time
    
    2024-12-18T22:09:08Z



== PREVIEW UPDATE ERROR:

    FailedToLaunchAppError: Failed to launch dk.codepod.Bookmark-Portal
    
    /Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug/Bookmark Portal.app
    
    ==================================
    
    |  [Remote] JITError
    |  
    |  ==================================
    |  
    |  |  [Remote] XOJITError
    |  |  
    |  |  XOJITError: Could not create code file directory for session: Permission denied



== PREVIEW UPDATE ERROR:

    FailedToLaunchAppError: Failed to launch dk.codepod.Bookmark-Portal
    
    /Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug/Bookmark Portal.app
    
    ==================================
    
    |  [Remote] JITError
    |  
    |  ==================================
    |  
    |  |  [Remote] XOJITError
    |  |  
    |  |  XOJITError: Could not create code file directory for session: Permission denied



== VERSION INFO:

    Tools: 16C5032a
    OS:    24C101
    PID:   6693
    Model: MacBook Pro
    Arch:  arm64e



== ENVIRONMENT:

    openFiles = [
        /Users/two/Developer/Bookmark Portal/Bookmark Portal/Views/BookmarkView.swift
    ]
    wantsNewBuildSystem = true
    newBuildSystemAvailable = true
    activeScheme = Bookmark Portal
    activeRunDestination = My Mac variant macos arm64
    workspaceArena = [x]
    buildArena = [x]
    buildableEntries = [
        Bookmark Portal.app
    ]
    runMode = JIT Executor



== SELECTED RUN DESTINATION:

    macOS 15.2 | macos | arm64 | MacBook 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: 00006000-0016515E3A04401E-macosx15.2-arm64-macos
    JIT Link Description {
        5:Bookmark Portal.app
    }
    



== SESSION GROUP 6479:

    workspace identifier: WorkspaceIdentifier(identifier: 9B58E9C4-D278-4C9B-B8C7-2328368A72C8)
    providers: [
        Preview Provider | Registry-BookmarkView.swift#1[preview] [Editor(6440)]
    ]
    translation units: [
        /Users/two/Developer/Bookmark Portal/Bookmark Portal/Views/BookmarkView.swift
    ]
    attributes: [
        Editor(6440):     []
    ]
    session: 6484
    request sessions: [
        Registry[Registry-BookmarkView.swift#1[preview] (line 30)]: not completed
    ]



== UPDATE SESSION 6484:

    Start Date: Wednesday, 18 December 2024 at 22.58.18 Central European Standard Time
    Timing {
        Elapsed Time: 10.974076986312866s
        18bfc2c5139a2563,756251898.545233,10.974076986312866s,,PreviewUpdateSession,id:6484
        bff67e29f0d83420,756251898.583089,0.006567955017089844s,,MakeBuildGraph,
        a5c1b3e3654db5df,756251898.595378,0.07855498790740967s,,WorkspaceBuild,
        a22932ed4b5c794d,756251898.678203,0.07782196998596191s,,AllBuiltTargetDescriptions,
        5fb6c091c134cef6,756251898.678299,0.007565021514892578s,,IDEBuiltTargetDescriptionRequest,
        42aed4a8c2f97e0e,756251898.685944,0.0697929859161377s,,ProcessBuiltTargetDescription,Bookmark_Portal
        692c9582d378b449,756251898.772092,0.31762099266052246s,,ThunkBuild,BookmarkView.swift
        fb13c2d3ed593b94,756251898.794263,0.19983899593353271s,,AgentLaunch,
    }
    Preview Preflight {
        UpdaterStore {
            updaterLimit: none
            expectedAbandonedIdentifiers: [6497, 6287, 6317, 6269]
        }
        My Mac {
            dvtDevice: My Mac
            buildNumber: 15.2 (24C101)
            arch: arm64e
        }
        host bundle: 
        dk.codepod.Bookmark-Portal {
            url: file:///Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug/Bookmark%20Portal.app
            version: 6489
            signingInformation: 
            Code Signing {
                identifier: dk.codepod.Bookmark-Portal
                identity: 2007EF4FB2A20097140DD72D58617839F5126BE7
                hasGetTaskAllow: false
                isSandboxed: true
            }
            attributes: [
                LaunchConfigArgumentsPreviewAttributesKey: ["-NSDocumentRevisionsDebugMode", "YES"],
                LaunchConfigEnvironmentVariablesPreviewAttributesKey: ["OS_ACTIVITY_TOOLS_OVERSIZE": "YES", "__XPC_DYLD_LIBRARY_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "SQLITE_ENABLE_THREAD_ASSERTIONS": "1", "PACKAGE_RESOURCE_BUNDLE_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "OS_LOG_DT_HOOK_PREFIX": "OSLOG-669A2D88-9C02-4099-B9B0-D44533611D54", "OS_ACTIVITY_TOOLS_PRIVACY": "YES", "DYLD_FRAMEWORK_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "TERM": "dumb", "OS_LOG_DT_HOOK_MODE": "0x07", "__XCODE_BUILT_PRODUCTS_DIR_PATHS": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "CFLOG_FORCE_DISABLE_STDERR": "1", "OS_LOG_TRANSLATE_PRINT_MODE": "0x80", "IDE_DISABLED_OS_ACTIVITY_DT_MODE": "1", "DYLD_LIBRARY_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "__XPC_DYLD_FRAMEWORK_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "DYLD_INSERT_LIBRARIES": "/Applications/Xcode.app/Contents/Developer/usr/lib/libLogRedirect.dylib"],
                AppExtensionIdentifierPreviewAttributeKey: nil,
                AgentCompanionAppBundleIdentifierKey: nil,
                AgentRoleKey: Previews,
                AgentRunModeKey: JIT Executor,
            ]
        }
        builtTargetDescriptions: Build Logs/ResolvedBuiltTargetDescriptions-request-1-dk.codepod.Bookmark-Portal.txt
    }
    Preview Provider {
        UpdaterStore {
            updaterLimit: none
            expectedAbandonedIdentifiers: [6497, 6287, 6317, 6269]
        }
        My Mac {
            dvtDevice: My Mac
            buildNumber: 15.2 (24C101)
            arch: arm64e
        }
        host bundle: 
        dk.codepod.Bookmark-Portal {
            url: file:///Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug/Bookmark%20Portal.app
            version: 6489
            signingInformation: 
            Code Signing {
                identifier: dk.codepod.Bookmark-Portal
                identity: 2007EF4FB2A20097140DD72D58617839F5126BE7
                hasGetTaskAllow: false
                isSandboxed: true
            }
            attributes: [
                LaunchConfigArgumentsPreviewAttributesKey: ["-NSDocumentRevisionsDebugMode", "YES"],
                LaunchConfigEnvironmentVariablesPreviewAttributesKey: ["OS_ACTIVITY_TOOLS_OVERSIZE": "YES", "__XPC_DYLD_LIBRARY_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "SQLITE_ENABLE_THREAD_ASSERTIONS": "1", "PACKAGE_RESOURCE_BUNDLE_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "OS_LOG_DT_HOOK_PREFIX": "OSLOG-669A2D88-9C02-4099-B9B0-D44533611D54", "OS_ACTIVITY_TOOLS_PRIVACY": "YES", "DYLD_FRAMEWORK_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "TERM": "dumb", "OS_LOG_DT_HOOK_MODE": "0x07", "__XCODE_BUILT_PRODUCTS_DIR_PATHS": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "CFLOG_FORCE_DISABLE_STDERR": "1", "OS_LOG_TRANSLATE_PRINT_MODE": "0x80", "IDE_DISABLED_OS_ACTIVITY_DT_MODE": "1", "DYLD_LIBRARY_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "__XPC_DYLD_FRAMEWORK_PATH": "/Users/two/Library/Developer/Xcode/DerivedData/Bookmark_Portal-dkfmyjbnmufgasbxtxohmncqbauk/Build/Products/Debug", "DYLD_INSERT_LIBRARIES": "/Applications/Xcode.app/Contents/Developer/usr/lib/libLogRedirect.dylib"],
                AppExtensionIdentifierPreviewAttributeKey: nil,
                AgentCompanionAppBundleIdentifierKey: nil,
                AgentRoleKey: Previews,
                AgentRunModeKey: JIT Executor,
            ]
        }
        builtTargetDescriptions: Build Logs/ResolvedBuiltTargetDescriptions-request-2-dk.codepod.Bookmark-Portal.txt
    }
    Build Graph {
        Bookmark Portal.app (#5)
           BrowserAvailability (#2)
              BrowserAvailability (#1)
           sourceFile(file:///Users/two/Developer/Bookmark%20Portal/Bookmark%20Portal/Views/BookmarkView.swift -> BookmarkView.swift) (#3)
           BookmarkView.swift (#4)
    }
    Update Plan {
        macOS [arm64 macosx15.2 macos] (MacBook Pro, 00006000-0016515E3A04401E-macosx15.2-arm64-macos), [], thinning enabled, thunking enabled) {
            Destination: My Mac dvtdevice-local-computer:localhost | default device for macos [
                Bookmark_Portal app - Previews {
                    execution point packs [
                        [source: BookmarkView.swift, role: Previews] (in Bookmark_Portal)
                    ]
                    translation units [
                        BookmarkView.swift (in Bookmark Portal.app)
                    ]
                    modules [
                        Bookmark Portal.app
                        BrowserAvailability
                        BrowserAvailability
                    ]
                    jit link description [
                        Bookmark Portal.app
                    ]
                }
            ]
        }
    }



== POWER STATE LOGS:

    18/12/2024, 22.46 Received power source state: Battery Powered (lowPowerMode: false, status: charged, level: 100%)
    18/12/2024, 22.46 No device power state user override user default value.Current power state: Full Power


Thanks for letting us know about this. Can you file a feedback with a sysdiagnose after reproducing the problem again? We'd like to see what kind of things the permissions subsystems are up to when this happens.

Xcode preview fails
 
 
Q