SwiftUI Preview Runtime linking failure

Swift Package:

I have an old objc library, that is added as XCFramework to swift package as a binary target.

targets: [
        .target(
            name: "CoreServices",
            dependencies: ["OldContainer"],
            path: "CoreServices"
        ),
        .binaryTarget(
            name: "OldContainer",
            path: "Frameworks/OldContainer.xcframework"
        ),
    ]

This serves the purpose, it builds fine and able to run on simulator. However this framework is breaking the Xcode previews.

Error:

== PREVIEW UPDATE ERROR:

    [Remote] JITError: Runtime linking failure
    
    Additional Link Time Errors:
    Symbols not found: [ _OBJC_CLASS_$_SCSecureServicesFactory ]
    
    ==================================
    
    |  [Remote] LLVMError
    |  
    |  LLVMError: LLVMError(description: "Failed to materialize symbols: { (static-Login, { __replacement_tag$1015 }) }")



== VERSION INFO:

    Tools: 16C5032a
    OS:    23G93
    PID:   38675
    Model: MacBook Pro
    Arch:  arm64e



== ENVIRONMENT:

    openFiles = [
        /Users/../Documents/GitHub/Packages/Login/Sources/Login/LoginView.swift
    ]
    wantsNewBuildSystem = true
    newBuildSystemAvailable = true
    activeScheme = Launch
    activeRunDestination = iPhone 16 Pro Max variant iphonesimulator arm64
    workspaceArena = [x]
    buildArena = [x]
    buildableEntries = [
        Login
        Login
    ]
    runMode = JIT Executor



== SELECTED RUN DESTINATION:

    Simulator - iOS 18.2 | iphonesimulator | arm64 | iPhone 16 Pro Max | no proxy



== EXECUTION MODE OVERRIDES:

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


Based on the error, SCSecureServicesFactory is an objc file inside the XCFramework. Since this is a binary target, I could not add a swift setting module map flag to the XCFramework.

Is there any workaround to get the previews working ? Or Am I blocked until the library is converted into swift ?

This is something we're aware of and actively investigating. And you're in luck! Xcode 16.3 beta 1 was just released and we've made changes attempting to address issues with XCFrameworks and packages. Can you download that and try that out?

If it still doesn't work, we need detailed diagnostics to dig in further.

  1. Download and install the logging profile on all devices involved. Instructions and profiles are available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift
  2. Reproduce the issue
  3. Click the "Diagnostics" button in the error banner in Previews' Canvas area (or if the banner is missing you can use the menu: Editor > Canvas > Diagnostics)
  4. In the sheet that appears, click "Generate Report" in the bottom left of the sheet
  5. Attach (or make from the folder) the resulting zip file to the bug report (will be named something like previews-diagnostics-0123456789.zip)

Generate the sysdiagnose(s) and attach those too.

Oh, one more thing. This fix needs a paired change in the OS layer. I see from your diagnostic message that you're previewing to an iOS simulator, so just downloading the Xcode 16.3 beta 1 will be fine because it will come with beta sims that have the paired OS change.

SwiftUI Preview Runtime linking failure
 
 
Q