In my Xcode app, I was attempting to use the #Playground macro to play around with some of the Foundation Model features to see if they would work for my iOS app. However, every time I used a #Playground macro, even if it was empty, it would receive the following error:
/var/folders/q2/x5b9x0y161bb2l_0yj1_j6wm0000gn/T/swift-generated-sources/@__swiftmacro_20PlaygroundMacroIssue0022ContentViewswift_tiAIefMX26_0_33_B691877350F20F2DFC040B9E585F4D10Ll0A0fMf_.swift:51:5 Main actor-isolated let '$s20PlaygroundMacroIssue0022ContentViewswift_tiAIefMX26_0_33_B691877350F20F2DFC040B9E585F4D10Ll0A0fMf_23PlaygroundContentRecordfMu_' can not be referenced from a nonisolated context
Here are my Xcode and system versions:
Mac is running the first public beta of Tahoe. iOS Simulator is running 26.0 dev beta 4. Xcode is Xcode 26 beta 4.
So, I went to try to reproduce the error in a blank iOS app project (the error above is the one that I reproduced in that project). Here are the steps that I took.
- I created a new iOS project in Xcode 26.
- I went into the ContentView.swiftthat was created for me and imported the Playgrounds module and created a blank #Playground at the bottom of the file.
- I then compiled the project and it ran just fine.
- To try to find out what the issue was, I looked at the concurrency settings. In my real app, Strict Concurrency Checking was set to Complete but was Minimal in my test project. So I went and changed that setting in my real app and it didn't fix anything.
- Next, I looked at the Swift Version, which turned out to be the culprit. My test app was running Swift 5 whereas the real app was running Swift 6. It seems to have crashed while running Swift 6, not 5.
I have trouble understanding what the error is saying. I have tried using the Code Intelligence feature to fix the bug but it hasn't helped.
Has anyone here experienced a similar bug? Is there something I can do to fix it or is this an error in Xcode that should be reported?
I have attached an iCloud link to my test project if anybody wants to see if they can reproduce the issue: here
Thanks!