Canvas fails with "Runtime Linking Failure" in Swift Package

I have a view inside a Swift Package that relies on an external Swift Package. My Preview Canvas breaks as soon as I use code from the external package:

import ComplexModule // From swift-numerics
import SwiftUI

struct MyView: View {
	// Commenting out this line will make Previews work
	let number: Complex<Double> = 123

	var body: some View {
		Text("Hello World")
	}
}

#Preview {
	MyView()
}

This is part of the error the preview emits:

== PREVIEW UPDATE ERROR:

    GroupRecordingError
    
    Error encountered during update group #33
    
    ==================================
    
    |  [Remote] JITError: Runtime linking failure
    |  
    |  Additional Link Time Errors:
    |  Symbols not found: [ _$sSd10RealModule0A0AAMc, _$s13ComplexModule0A0VMn, _$s13ComplexModule0A0V14integerLiteralACyxG07IntegerD4TypeQz_tcfC ]
    |  
    |  ==================================
    |  
    |  |  [Remote] LLVMError
    |  |  
    |  |  LLVMError: LLVMError(description: "Failed to materialize symbols: { (static-MyTarget, { __replacement_tag$1 }) }")

Did anyone else see this before?

Hi,

Sorry to hear you are having problems getting previews working. 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, and attach those too
Canvas fails with "Runtime Linking Failure" in Swift Package
 
 
Q