Open insidegui opened 1 year ago
This seems to be an issue with SwiftData. I was having the same problem, and removing the @Model macro annotation (and associated code) corrected the preview issue. Obviously not ideal, but helps narrow it down.
can confirm, my app I had converted to SwiftData no longer builds
Turns out this is listed as a known issue in the Xcode 15 beta 3 release notes:
Managed to get mine to build (first one took a while), but not being able to use previews is not very convenient at all.
Can confirm this as well. Can build to simulator and phone with no issue but the preview canvas fails due the @Model macro associated with SwiftData.
Turns out this is listed as a known issue in the Xcode 15 beta 3 release notes:
![]()
Good catch! I need to be better in the future about going line-by-line in the release notes. Thanks for pointing this one out!
I have the same issue when building the app to place it on my device. Is there a workaround for this to test the app on our devices?
having the same problem. What is strange is that I erased the Hard Drive and did a fresh install and then a fresh install of Xcode Beta 3 and right away, I am having the same problem. And again, once I remove @Model the problem goes away
Undefined symbols:
Linker command failed with exit code 1 (use -v to see invocation)
Same here :( How can such a major bug slip through? Or is there a way to use SwiftData without the @Model macro?
Same here :( How can such a major bug slip through? Or is there a way to use SwiftData without the @model macro?
You can use SwiftData but you have to comment out the new #Previews which makes is a bit inconvenient
Same here :( How can such a major bug slip through? Or is there a way to use SwiftData without the @model macro?
You can use SwiftData but you have to comment out the new #Previews which makes is a bit inconvenient
Ah… I haven’t tried using the old Preview struct. If this still works, it’s only half as bad.
not fixed on beta 4
Yup and the good old PreviewProvider also does not work :<
The issue only appears with @model macro when using SwiftData. Even with old PreviewProvider, it does not work. And beta 4 does not fix the issue... (it is still written as a known issue)
This has been mentioned in the Xcode 14 beta 4 release notes:
This has been mentioned in the Xcode 14 beta 4 release notes:
- Previewing view code in a SwiftData app results in a linker failure for the canvas despite that code compiling successfully for device and simulator. (111657477) Workaround: Run your app in the simulator to test your UI instead of using Previews.
I tried to run my app on my own iPhone, it still didn't work...
This has been mentioned in the Xcode 14 beta 4 release notes:
Previewing view code in a SwiftData app results in a linker failure for the canvas despite that code compiling successfully for device and simulator. (111657477)
Workaround: Run your app in the simulator to test your UI instead of using Previews.
I tried to run my app on my own iPhone, it still didn't work...
Must be something different then. For me both simulator and own device do work.
Must be something different then. For me both simulator and own device do work.
Could you show me a quick example, with a simple @model class, with a single view?
Simulator and devices all work for me but the #Preview code must be commented out or previews disabled in the editor otherwise I get the error
I also commented out the function to generate the preview #Preview, the error disappears. However, it's not very convenient to rebuild the project every time, especially when making small changes in the interface. Hopefully, someone will fix this issue soon.
Look's like the problem is solved by installing Xcode 15 beta 5 ✅
Details
What version of Xcode are you using? 15.0 beta 3 (15A5195k)
Did you see an error message? Yes
What was the error?
ld: Undefined symbols: unsafeMutableAddressor of self
Description
Xcode fails to build a simple iOS app target for previews when it contains models that use SwiftData’s
@Model
macro.Steps to reproduce:
Expected results:
The app preview should compile and run successfully.
Actual results:
The app preview fails to compile with the following linker errors:
Notes: