I'm experiencing the same thing still. Do you happen to have any updates to this?
Post
Replies
Boosts
Views
Activity
I would also really like to see how Core Data could be incorporated into this.
@andrewbuilder's answer is excellent. The only thing that needs to be changed is making "persistentContainer" a let instead of a lazy var. As as lazy var, the persistent container will not load in time for the first view. This caused a crash when my first view was trying to access my core data persistent container. However by making it a constant variable, this issue went away.
This is still an issue for me as well. Anybody have any updates?
This is happening to me on Xcode 12 beta 4 with iOS 14 beta 4, but only on a device.
I’m having this issue in the iOS 14 GM.
I’m getting this error on Xcode Version 12.2 beta 3 (12B5035g) with iOS 14.2 beta 4. It works partially in the simulator but not on a real device.
I've been having this issue to an I found that changing from this
struct Test_Previews: PreviewProvider {
static var previews: some View {
Test()
.environment(\.managedObjectContext, CoreDataManager.shared.context)
}
}
to this has been the solution for me. No idea why this works, but it does.
struct Test_Previews: PreviewProvider {
static var previews: some View {
let context = CoreDataManager.shared.context
return Test()
.environment(\.managedObjectContext, context)
}
}
As thisisnotmikey said, you can check the size of the data and see if its 42 bytes, however this also doesn't work because anytime you use the eraser, it adds to the data size. So even if you have a blank canvas and only use the erase, the data size will ballon.
canvasView.drawing.strokes.isEmpty seems to work well. So does canvasView == CGRect(origin: CGPoint(x: CGFloat.infinity, y: CGFloat.infinity), size: .zero).
You have to add a large delay for @FocusState to work inside of a sheet. Here is a basic example.
enum FocusableField: Hashable {
case email
case password
}
struct ContentView: View {
@State private var show = false
var body: some View {
Button("Show"){
show.toggle()
}
.sheet(isPresented: $show){
SheetView()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.previewLayout(.sizeThatFits)
}
}
struct SheetView: View{
@State private var email = ""
@State private var password = ""
@FocusState private var focus: FocusableField?
var body: some View{
NavigationView {
Form {
TextField("email", text: $email, prompt: Text("email"))
.focused($focus, equals: .email)
SecureField("password", text: $password, prompt: Text("password"))
.focused($focus, equals: .password)
}
.navigationTitle("Sign in")
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
focus = .email
}
}
}
}
}
Same issue with me.
I ended up having to create a UICollectionViewCompositionalLayout subclass, but the solution works really well. You can see the complete solution here.
I’m also having this issue (Instruments 14.0.1). Did you ever find a fix?
Did you ever find a solution?