Previews are not building for the SwiftDataCardSample project.

I set my active schema to SwiftDataCardSampleEnd, open ContentView.swift, and bring up the Canvas. When I click the little refresh button I get the follow error from Canvas:

== DATE:
Friday, July 14, 2023 at 9:02:26 AM Eastern Daylight Time
2023-07-14T13:02:26Z
== PREVIEW UPDATE ERROR:
SchemeBuildError: Failed to build the scheme ”SwiftDataFlashCardSampleEnd”
linker command failed with exit code 1 (use -v to see invocation)
Link SwiftDataFlashCardSample (arm64):
ld: Undefined symbols:
unsafeMutableAddressor of self #1 : SwiftDataFlashCardSample.Card in SwiftDataFlashCardSample.Card.creationDate.init : Foundation.Date, referenced from:
SwiftDataFlashCardSample.Card.creationDate.init : Foundation.Date in Card.o
unsafeMutableAddressor of self #1 : SwiftDataFlashCardSample.Card in SwiftDataFlashCardSample.Card.back.init : Swift.String, referenced from:
SwiftDataFlashCardSample.Card.back.init : Swift.String in Card.o
unsafeMutableAddressor of self #1 : SwiftDataFlashCardSample.Card in SwiftDataFlashCardSample.Card.front.init : Swift.String, referenced from:
SwiftDataFlashCardSample.Card.front.init : Swift.String in Card.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've made a similar preview in another project where I define a model and I try to use that model in a SwiftUI Canvas preview. I get a very similar error. Basically Canvas is saying it can't find the symbols for the properties on the type.

Is there something I'm missing here? Some hidden build setting I need to flip. Or is this just busted?

Here's the bottom half of the error if Apple is watching this post:

== VERSION INFO:
Tools: 15A5195m
OS: 23A5286i
PID: 29967
Model: Mac Studio
Arch: arm64e
== ENVIRONMENT:
openFiles = [
/Users/bdunay3/Desktop/BuildingADocumentBasedAppUsingSwiftData/End/FlashCard/Views/ContentView.swift
]
wantsNewBuildSystem = true
newBuildSystemAvailable = true
activeScheme = SwiftDataFlashCardSampleEnd
activeRunDestination = My Mac variant macos arm64
workspaceArena = [x]
buildArena = [x]
buildableEntries = [
SwiftDataFlashCardSample.app
]
runMode = Dynamic Replacement
== SELECTED RUN DESTINATION:
name = My Mac
eligible = true
sdk = Optional(<DVTSDK:0x10eb17360:'macosx14.0':macOS 14.0:<DVTFilePath:0x6000028b8f50:'/Applications/Xcode-15.0.0-Beta.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk'>>)
variant = Optional("macos")
device = Optional(<DVTLocalComputer: 0x291b0a730 (My Mac | arm64e)>)
== SELECTED RUN DESTINATION:
macOS 14.0 | macos | arm64 | Mac Studio | no proxy
== PACKAGE RESOLUTION ERRORS:
== REFERENCED SOURCE PACKAGES:
== SESSION GROUP 2637:
workspace identifier: WorkspaceIdentifier(identifier: F623C971-5AC9-46B9-9C82-D7F18AD4FF9A)
providers: [
Preview Provider | Registry-ContentView.swift#1 [Editor(2608)]
]
translation units: [
/Users/bdunay3/Desktop/BuildingADocumentBasedAppUsingSwiftData/End/FlashCard/Views/ContentView.swift
]
attributes: [
Editor(2608): []
]
session: 2638
request sessions: [
Registry[ContentView.swift #1 (line 35)]: not completed
]
== UPDATE SESSION 2638:
Start Date: Friday, July 14, 2023 at 9:02:16AM Eastern Daylight Time
Preview Provider {
UpdaterStore {
updaterLimit: none
expectedAbandonedIdentifiers: []
}
My Mac {
dvtDevice: My Mac
buildNumber: 14.0 (23A5286i)
arch: arm64e
}
}
Preview Preflight {
UpdaterStore {
updaterLimit: none
expectedAbandonedIdentifiers: []
}
My Mac {
dvtDevice: My Mac
buildNumber: 14.0 (23A5286i)
arch: arm64e
}
}
Build Graph {
target app SwiftDataFlashCardSample.app (#1)
translationUnit ContentView.swift (#2)
Preview Preflight | Registry-ContentView.swift#1: from Editor(2608) for local Preview Preflight | Registry-ContentView.swift#1: from Editor(2608) for local (#3)
Preview Provider | Registry-ContentView.swift#1 [Editor(2608)] Preview Provider | Registry-ContentView.swift#1 [Editor(2608)] (#4)
}
Update Plan {
macOS [arm64 macosx14.0 macos] (Mac Studio, 00006022-001808603C02201E-macosx14.0-arm64-macos), [], thinning enabled) {
Destination: My Mac dvtdevice-local-computer:localhost | default device for macos [
SwiftDataFlashCardSample app - Previews {
execution points [
point Preview Preflight | Registry-ContentView.swift#1: from Editor(2608) for local
provider SwiftDataFlashCardSample.Registry[ContentView.swift #1 (line 35)]
]
translation units [
ContentView.swift (in SwiftDataFlashCardSample.app)
]
modules [
SwiftDataFlashCardSample.app
]
}
]
}
}
== POWER STATE LOGS:
7/14/2023, 9:02AM Received power source state: Externally Powered
7/14/2023, 9:02AM No device power state user override user default value.Current power state: Full Power

It is a bug. In Beta 3 it was possible to embed the preview code in MainActor.assumeIsolated { }, but this patch no longer works in Beta 4. They are now recommending to run the SwiftData apps in the simulator or a device until they fix the bug.

Thank you! If possible could you post a link to where you found that information. Just trying to keep track of current state for when boss asks.

Thanks again!!

The information about Previews not working with SwiftData is listed in the release notes for Xcode 15 Beta 4.

Hope this helps.

Previews are not building for the SwiftDataCardSample project.
 
 
Q