Post

Replies

Boosts

Views

Activity

The compiler is unable to type-check this expression in reasonable time in Xcode 12 with SwiftUI
I've just begun running into this error and I've seen that a few others have had this problem as well but there never seems to be a general solution. Full error: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions I know my code isn't necessarily optimized per se but I don't think this should be happening var body: some View {         return NavigationView {             List {                 ForEach(tasks, id: \.dueDate) {                     TaskRow(task: $0)                 }.onDelete(perform: deleteTask)                 Section(header: Text("Projects")                             .font(.title2)                             .fontWeight(.bold)                             .foregroundColor(Color.pink)) {                     ForEach(projects, id: \.projectTitle) {                         ProjectRow(project: $0)                     }.onDelete(perform: deleteProject)                 }             }.toolbar {                 ToolbarItem (placement: .primaryAction) {                     #if os(iOS) EditButton() .padding(10) .background(Color.blue) .foregroundColor(.white) .cornerRadius(10)                  #endif                 }                 ToolbarItem (placement: .bottomBar) {                     Button(action:                         self.isAddingTask = true                         self.isAddingProject = false                         self.isPresenting = true                     }) {                         Text("Add Task")                             .fontWeight(.semibold)                    }.padding(10) .background(Color.blue) .foregroundColor(.white) .cornerRadius(10)                 }                 ToolbarItem (placement: .bottomBar) {                     Button(action: {                         self.isAddingTask = false                         self.isAddingProject = true                         self.isPresenting = true                     }) {                         Text("Add Project")                             .fontWeight(.semibold)                   }.padding(10) .background(Color.pink) .foregroundColor(.white) .cornerRadius(10)                 }             }             .sheet(isPresented: $isPresenting) {                 if isAddingProject {                     AddProject() { projectTitle in                         self.addProject(projectTitle: projectTitle)                         resetModal()                     }                 } else if isAddingTask {                     AddTask() { taskDescription, dueDate in                         self.addTask(taskDescription: taskDescription, dueDate: dueDate)                         resetModal()                     }                 }             }             .navigationBarTitle(Text("Tasky"))         } The error says it's happening at the Navigation View but I have a sneaking suspicion Xcode doesn't actually know.
15
4
49k
Mar ’23
The compiler is unable to type-check this expression in reasonable time in Xcode 12 with SwiftUI
I've just begun running into this error and I've seen that a few others have had this problem as well but there never seems to be a general solution. Full error: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions I know my code isn't necessarily optimized per se but I don't think this should be happening var body: some View {         return NavigationView {             List {                 ForEach(tasks, id: \.dueDate) {                     TaskRow(task: $0)                 }.onDelete(perform: deleteTask)                 Section(header: Text("Projects")                             .font(.title2)                             .fontWeight(.bold)                             .foregroundColor(Color.pink)) {                     ForEach(projects, id: \.projectTitle) {                         ProjectRow(project: $0)                     }.onDelete(perform: deleteProject)                 }             }.toolbar {                 ToolbarItem (placement: .primaryAction) {                     #if os(iOS) EditButton() .padding(10) .background(Color.blue) .foregroundColor(.white) .cornerRadius(10)                  #endif                 }                 ToolbarItem (placement: .bottomBar) {                     Button(action:                         self.isAddingTask = true                         self.isAddingProject = false                         self.isPresenting = true                     }) {                         Text("Add Task")                             .fontWeight(.semibold)                    }.padding(10) .background(Color.blue) .foregroundColor(.white) .cornerRadius(10)                 }                 ToolbarItem (placement: .bottomBar) {                     Button(action: {                         self.isAddingTask = false                         self.isAddingProject = true                         self.isPresenting = true                     }) {                         Text("Add Project")                             .fontWeight(.semibold)                   }.padding(10) .background(Color.pink) .foregroundColor(.white) .cornerRadius(10)                 }             }             .sheet(isPresented: $isPresenting) {                 if isAddingProject {                     AddProject() { projectTitle in                         self.addProject(projectTitle: projectTitle)                         resetModal()                     }                 } else if isAddingTask {                     AddTask() { taskDescription, dueDate in                         self.addTask(taskDescription: taskDescription, dueDate: dueDate)                         resetModal()                     }                 }             }             .navigationBarTitle(Text("Tasky"))         } The error says it's happening at the Navigation View but I have a sneaking suspicion Xcode doesn't actually know.
Replies
15
Boosts
4
Views
49k
Activity
Mar ’23