How to fix the Core Data / SwiftUI 2.0 template in Xcode 12

In Xcode 12, does the CoreData / SwiftUI 2.0 template give you an app that only displays a white screen? Well...

In ContentView, replace the body with this...

Code Block swiftvar body: some View {	NavigationView {		List {			ForEach(items) { item in				Text("Item at \(item.timestamp!, formatter: itemFormatter)")			}			.onDelete(perform: deleteItems)		}		.toolbar {			ToolbarItem(placement: .navigationBarLeading) {				#if os(iOS)				EditButton()				#endif			}			ToolbarItem(placement: .navigationBarTrailing) {				Button(action: addItem) {					Label("Add Item", systemImage: "plus")				}			}		}	}}


Nice suggestion! Thanks for posting.

The template in Xcode 12.2 beta produces a blank white screen on iOS
Still an issue in the public release...
I've fixed this for Xcode 12.3 default CoreData code.
Answered here :https://stackoverflow.com/a/65315807/1890317
Hi there,

If you add a new navigation view and a new horizontal stack view in the body then you can solve the blank screen issue with an ease.

Here goes the code:

Code Block swiftvar body: some View {        NavigationView { // NEW            List {                ForEach(items) { item in                    Text("Item at \(item.timestamp!, formatter: itemFormatter)")                }                .onDelete(perform: deleteItems)            }            .toolbar {                HStack { // NEW                  #if os(iOS)                    EditButton()                  #endif                  Button(action: addItem) {                      Label("Add Item", systemImage: "plus")                  }              } //: HSTACK          }      } //: NAVIGATION}

This can fix this problem until engineers in Cupertino updates this Core Data template.

Until then happy coding!

How to fix the Core Data / SwiftUI 2.0 template in Xcode 12
 
 
Q