I have noticed that Xcode fails to compile with
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
You can execute the below demo project to recreate the error. Once you uncomment confirmationDialog entries 11+ it fails to compile.
//
// ContentView.swift
// confDialogTest
//
// Created by Max on 13.06.22.
//
import SwiftUI
struct ContentView: View {
@State private var showingConf1 = false
@State private var showingConf2 = false
@State private var showingConf3 = false
@State private var showingConf4 = false
@State private var showingConf5 = false
var body: some View {
Button(role: .destructive) {
self.showingConf1.toggle()
} label: {
Label("Conf 1", systemImage: "trash.fill")
}
.padding()
Button(role: .destructive) {
self.showingConf2.toggle()
} label: {
Label("Conf 2", systemImage: "trash.fill")
}
.padding()
Button(role: .destructive) {
self.showingConf3.toggle()
} label: {
Label("Conf 3", systemImage: "trash.fill")
}
.padding()
Button(role: .destructive) {
self.showingConf4.toggle()
} label: {
Label("Conf 4", systemImage: "trash.fill")
}
.padding()
Button(role: .destructive) {
self.showingConf5.toggle()
} label: {
Label("Conf 5", systemImage: "trash.fill")
}
// .padding()
.confirmationDialog("Select location", isPresented: $showingConf1, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf2, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf3, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf4, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
//next group is dialogs 6-10
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
//next group is dialogs 11-15
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
//next group is dialogs 16-20
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Whiel it is easy to fix here if I just move some confirmationDialogs to another Button view, I have the same problem in another problem where I have to add many modifiers to a NavigationLink in a List View and there I cannot move it around ... :/
Any ideas what to do here?
Max