For anyone else stuck in this issue see the SO answer I accepted here:
https://stackoverflow.com/a/78106284/1735584
Group docs: https://developer.apple.com/documentation/swiftui/group
Use a group to collect multiple views into a single instance, without affecting the layout of those views, like an HStack, VStack, or Section would.
Post
Replies
Boosts
Views
Activity
I'm having the same issue and this just looks like I've done something wrong as a developer with this error rather than it not being supported by Xcode/Previews any more - kind of sucks as a dev experience as I could have just wasted a ton of time trying to fix something that isn't broken
Specifically the compiler errors with:
Failed to produce diagnostic for expression; please submit a bug report (Swift.org - Contributing)
On the parent function the @Bindable is inside of
and with a
Command SwiftCompile failed with a nonzero exit code
In the app target.
Example project: https://github.com/adammcarter/observable-example/
https://github.com/adammcarter/observable-example/blob/main/observabletest/ContentView.swift
Thanks for the workaround... shame this issue is still around in iOS 18 Beta 2 / Xcode 16 beta 2.
For anyone else, my code has to look like this :
@State private var path = NavigationPath()
// body {
// Navigation Split View Detail ... {
NavigationStack(path: $path.animation(.linear(duration: 0))) {
VStack {
Text(document.imageUrl?.absoluteString ?? "")
.frame(maxWidth: .infinity, maxHeight: .infinity)
.id(document.imageUrl)
.transition(.slide)
.overlay(
alignment: .bottomTrailing,
content: makePrevNextView
)
}
}
// }
// }
Note, the VStack is necessary and fails without it...
Did you find a fix for this? I'm seeing the same thing...
Failed to create document. Error: Error Domain=com.apple.DocumentManager Code=2 "No location available to save “Untitled.myFile”." UserInfo={NSLocalizedDescription=No location available to save “Untitled.myFile”., NSLocalizedRecoverySuggestion=Enable at least one location to be able to save documents.}
Thanks for pointing me in the right direction.
I had no idea about UITextInteraction but the sample code here made the caret show up for me 👏🏻
https://developer.apple.com/documentation/uikit/uitextinteraction
I'm working on an older project so apologies for my fuzzy memory.
I think my initial attempt was to use TextKit2 now I'm looking at the code. But there was a limit of only using one NSTextContainer.
Am I right in thinking if I wanted to create that multi-page setup I'd need each "page" to have its own layer that's drawn in to?
Similar to the Bubble TextKit2 example code does?
I found this forum post which it sounds like it was going to change to add multiple containers,
So I'm quite confused in this...
https://developer.apple.com/forums/thread/682251
I've found the documentation on this topic to be really awful with little to explain the relationships between all these elements and the existing documentation to be outdated using TextKit1
(Note the below is archived)
https://developer.apple.com/library/archive/documentation/TextFonts/Conceptual/CocoaTextArchitecture/TextSystemArchitecture/ArchitectureOverview.html
@DTS Engineer is there any docs for TextKit2 and how its new classes interface with each other?
The TextKit2 sample code has a lot of nuance which is impossible to learn unless you know it exists
Thanks @DTS Engineer for the suggestion and code!
In answer to the second part, I’m wanting to recreate a Pages/Word style document writing app that has custom rendering of the same body of text over multiple “pages“.
I’ve got a rough working prototype using custom TextKit2 drawing to views but implementing UITextInput manually is A LOT of work.
I was hoping instead to make use of UITextView given I only want to control the layout (drawing) of the fragments and essentially get the text editing experience for free.
But this has proved very difficult (there’s also almost no documentation on this topic other than 2 WWDC videos so it’s a much more difficult task).
I‘ve been able to achieve the above by using a UITextView (without subclassing) and using custom rendering but this draws the text on top of the UITextView in its multiple pages, duplicating the drawn text (not what I want as it effectively draws the UITextView’s text on a layer below as normal, then my text is rendered above it in separate page views, added as subviews to the UITextView)
So I thought perhaps the next step would be to subclass UITextView for more control.
Hopefully you can see what I’m trying to do, does that make sense?