So I have an XCode project that has 2 .swift files that shares a variable through SwiftUI's @Binding.
The project builds and run through the Simulator just fine.
But whenever I try to use Preview on the secondary file (which receives the variable from the main file), it crashes after succesfully built saying "MyProject.app crashed: communication with the app was interrupted".
I can still test the project by:
- Using the Simulator
- Previewing the main file (ContentView.swift) (Yes previewing the main file works fine)
But its really time consuming for building and testing since it takes several actions in my app to get to the view of the secondary file and everytime Xcode refresh the app restarts.
Here is my code for the sondary file:
import SwiftUI
struct Menu_Screen : View {
@Binding var TapToBegin:Bool
var body: some View {
Button(action: {
}) {
Text("A Button").color(.white).frame(width: TapToBegin ? 50:0, height: TapToBegin ? 100:0).background(Color.blue).cornerRadius(10)
}
} }
#if DEBUG
struct Menu_Screen_Previews : PreviewProvider {
@State static var BoolVariable = true
static var previews: some View {
Menu_Screen(TapToBegin: $BoolVariable)
} }
#endif
I would like to use Preview with the secondary file so I can always stay on its view and save time. Any help would be very appreciated.