Navigation Link - presentationMode.Dismiss problem XCode 12.5

I updated my XCode to 12.5 today and all of my views with navigationlinks are working, except that in the subview when my "cancel" button is pressed and I issue

self.presentationMode.wrappedValue.dismiss()
upon returning to the parent view I'm seeing

"Unable to present. Please file a bug."

Worked just fine in 12.4.... I have many areas that are now broken...

Any ideas would be GREATLY appreciated...

I have found that if there are two or less navigation links in a parent view this does not occur...

That would be a tremendous redesign and recode to figure how to do that...

PARENT CODE:

i
  var body: some View {
     
      LazyVGrid(columns: columns, spacing: 10) {
         
        Text("BUDGETED INCOME")
          .foregroundColor(self.labelColor)
          .padding(.leading, 10)
         
        NavigationLink(destination: BudgetedIncomeView(account_code: self.account_code, budget_year: self.budget_year, budget_month: self.budget_month, displayMoYr: self.displayMonthYearString)){
        Text("\(self.expected_income, specifier: "%.2f")")
          .foregroundColor((self.expected_income < 0) ? self.negativeColor : self.numberColor)
          .background(self.globalSettings.globalViewPaleYellowColor)
          .border(Color.yellow)
        }
         
        NavigationLink(destination: BudgetedIncomeReceivedView(account_code: self.account_code, budget_year: self.budget_year, budget_month: self.budget_month, displayMoYr: self.displayMonthYearString)){
        Text("\(self.expected_income_received, specifier: "%.2f")")
          .foregroundColor((self.expected_income_received < 0 ) ? self.negativeColor : self.numberColor)
          .background(self.globalSettings.globalViewPaleYellowColor)
          .border(Color.yellow)
          .padding(.trailing, 15)
        }
         
        Text("UNPLANNED INCOME")
          .foregroundColor(self.labelColor)
          .padding(.leading, 70)

        Spacer()
        NavigationLink(destination: BudgetedIncomeUnexpectedView(account_code: self.account_code, budget_year: self.budget_year, budget_month: self.budget_month, displayMoYr: self.displayMonthYearString)){
        Text("\(self.unexpected_income_received, specifier: "%.2f")")
          .foregroundColor((self.unexpected_income_received < 0 ) ? self.negativeColor : self.numberColor)
          .background(self.globalSettings.globalViewPaleYellowColor)
          .border(Color.yellow)
          .padding(.trailing, 15)
        }
        //*********** NEXT LINE ************//
         
        Text("BEG. BAL. PLUS INCOME")
          .foregroundColor(self.labelColor)
          .padding(.leading, 10)

        Spacer()
         
        Text("\(self.beginning_balance + self.expected_income_received + self.unexpected_income_received, specifier: "%.2f")")
          .foregroundColor((self.beginning_balance + self.expected_income_received + self.unexpected_income_received < 0 ) ? self.negativeColor : self.numberColor)
          .padding(.trailing, 15)
         
      } // END OF LAZYVGRID
      .font(.title)
  } // END OF BODY
}

SUBVIEW CODE:


//
// BudgetedIncomeView.swift
// ManagingYourMoney
//
// Created by Robert Petruzzelli on 4/23/21.
//

import SwiftUI

struct BudgetedIncomeView: View {
   
  @State var recordDeleted: Bool = false
  @State var isAdding: Bool = false
   
  @State var account_code: Int
  @State var budget_year: Int
  @State var budget_month: Int
  @State var displayMoYr: String
   
  @State var budgetRec = BudgetedIncome.BudgetedIncomeRecord()
   
  // Environment and ObservedObjects
  @EnvironmentObject var budget: Budget
  @Environment(\.presentationMode) var presentationMode
  @Environment(\.editMode) var editMode
   
  // Array of Budgeted Expense records for View List
  var budgetedIncome: [BudgetedIncome.BudgetedIncomeRecord] {
    return BudgetedIncome.shared.selectBudgetedIncomeForAccountWithMonthAndYear(withAccountCode: self.account_code, withYear: self.budget_year, withMonth: self.budget_month)
  }
   
  var body: some View {
    ZStack {
      VStack  {
        BudgetedIncomeHeader(headerText: "Budgeted")
          .padding(.top, 10)
        List {
          ForEach (self.budgetedIncome, id: \.self) { budgetRecord in
            BudgetedExpenseRow(
              description: budgetRecord.description,
              expense_amount: NumberFormatter.roundToPlaces(value: budgetRecord.income_budget, places: 3),
              category: budgetRecord.category,
              hidden: budgetRecord.hidden
            )
            .deleteDisabled((self.editMode?.wrappedValue == .active ) ? false : true)
            .contentShape(Rectangle())
            .onTapGesture {
              budgetRec = budgetRecord
              self.isAdding.toggle()
            } // END OF ONTAPGESTURE
          } // END OF FOREACH
          .onDelete(perform: self.delete)
        } // END OF LIST
         
        BudgetedIncomeFooter(accountCode: $account_code, budgetYear: $budget_year, budgetMonth: $budget_month)
          .padding(.top, 5)
         
      } // END OF VSTACK
    } // END OF ZSTACK
    .onAppear(){
       
    }
    .navigationBarTitle("Budgeted Income for \(self.displayMoYr)")
    .navigationBarBackButtonHidden(true)
    .navigationBarItems(
      leading:
        Button(action: {
          if self.recordDeleted {
            self.budget.updated += 1
            self.recordDeleted = false
          }
          self.presentationMode.wrappedValue.dismiss()
        }, label: {
          Text("Cancel")
        })
      ,
      trailing:
        HStack {
          EditButton()
          Button(action: {
            self.isAdding.toggle()
          }, label: {
            Image(systemName: "plus")
          })
        }
       
    ) // END OF NAVIGATION VIEW
     
  } // END OF BODY VIEW
   
  func delete(at offsets: IndexSet) {
    offsets.forEach { index in
      //      let budgetIncome = self.budgetedIncome[index]
       
      //      deleteBudgetedExpenseAndDetailFiles(budRec: budgetExpense)
       
      self.recordDeleted = true
       
    }
  }
} // END OF STRUCT VIEW

struct BudgetedIncomeView_Previews: PreviewProvider {
  static var previews: some View {
    BudgetedIncomeView(account_code: 12345678,
              budget_year: 2020,
              budget_month: 12,
              displayMoYr: "December-2020")
      .environmentObject(ApplicationSettings())
      .environmentObject(Budget())
      .environmentObject(GlobalSettings())
  }
}

Clicking on the cancel button and returning to the parent is when the log item occurs.


Answered by OOPer in 674244022
Can you show a complete code which can reproduce the issue so that readers can easily run it?

With easily testable code, more readers would try to find how to work around this issue.
Accepted Answer
Can you show a complete code which can reproduce the issue so that readers can easily run it?

With easily testable code, more readers would try to find how to work around this issue.
HERE IS CODE THAT COMPILES AND RUNS .... This works fine in XCode 12.4 but throws the error in XCode 12.5

import SwiftUI

struct SetupMenuView: View {
   
  var body: some View {
     
    NavigationView {
       
      VStack(alignment: .leading) {
         
        Divider().background(Color.black)
  
        NavigationLink(destination: SubView01()) {
          Text("SubView01")
            .foregroundColor(.black)
            .font(.largeTitle)
        }
        .padding(.leading, 25)
         
        Divider().background(Color.black)
         
        NavigationLink(destination: SubView02()){
          Text("SubView02")
            .foregroundColor(.black)
            .font(.largeTitle)
        }
        .padding(.leading, 25)
         
        Divider().background(Color.black)
         
        NavigationLink(destination: SubView03()) {
          Text("SubView03")
            .foregroundColor(.black)
            .font(.largeTitle)
        }
        .padding(.leading, 25)
         
        Divider().background(Color.black)
         
        NavigationLink(destination: SubView04()) {
          Text("SubView04")
            .foregroundColor(.black)
            .font(.largeTitle)
        }
        .padding(.leading, 25)
         
        Divider().background(Color.black)
        //        }
      } // VSTACK END
      .padding(.top, 25)
      .frame(minWidth: 0,
          maxWidth: .infinity,
          minHeight: 0,
          maxHeight: .infinity,
          alignment: .topLeading
      )
      .navigationBarTitle("SubView Menu Setup", displayMode: .inline)
    }
    .navigationViewStyle(StackNavigationViewStyle())
     
  }
   
}

SUBVIEW 01


import SwiftUI

struct SubView01: View {
   
  @Environment(\.presentationMode) var presentationMode
   
  var body: some View {
     
    ZStack {
      VStack {
        Text("This is the sub view 01.")
          .font(.largeTitle)
      }
    }
    .navigationBarBackButtonHidden(true)
    .navigationBarTitle("SubView01", displayMode: .inline)
    .navigationBarItems(
      leading:
        Button(action: {
          self.presentationMode.wrappedValue.dismiss()
        }, label: {
          Text("Cancel")
        })
      ,
      trailing:
        HStack {
          EditButton()
            .padding()
        }
    )
  }
}

SUBVIEW 02

import SwiftUI

struct SubView02: View {
   
  @Environment(\.presentationMode) var presentationMode
   
  var body: some View {
     
    ZStack {
      VStack {
        Text("This is the sub view 02.")
          .font(.largeTitle)
      }
    }
    .navigationBarBackButtonHidden(true)
    .navigationBarTitle("ASubView02",displayMode: .inline)
    .navigationBarItems(
      leading:
        Button(action: {
          self.presentationMode.wrappedValue.dismiss()
        }, label: {
          Text("Cancel")
        })
      , trailing:
        HStack {
          EditButton()
            .padding()
        }
    )
  }
}

SUBVIEW 03


import SwiftUI

struct SubView03: View {
   
  @Environment(\.presentationMode) var presentationMode
   
  var body: some View {
    ZStack {
      VStack {
        Text("This is the sub view 03.")
          .font(.largeTitle)
      }
    }
    .navigationBarBackButtonHidden(true)
    .navigationBarTitle("SubView03", displayMode: .inline)
    .navigationBarItems(
      leading:
        Button(action: {
          self.presentationMode.wrappedValue.dismiss()
        }, label: {
          Text("Cancel")
        })
      ,
      trailing:
        HStack {
          EditButton()
            .padding()
        }
    )
  }
}

SUBVIEW 04


import SwiftUI

struct SubView04: View {
   
  @Environment(\.presentationMode) var presentationMode
   
  var body: some View {
    ZStack {
      VStack {
        Text("This is the sub view 04.")
          .font(.largeTitle)
      }
    }
    .navigationBarBackButtonHidden(true)
    .navigationBarTitle("SubView04", displayMode: .inline)
    .navigationBarItems(
      leading:
        Button(action: {
          self.presentationMode.wrappedValue.dismiss()
        }, label: {
          Text("Cancel")
        }
        )
      ,
      trailing:
        HStack{
          EditButton()
            .padding()
        }
    )
  }
}
Thanks for showing the new code.
I tried it both with Xcode 12.4 and 12.5, and only in case of 12.5, I could see Unable to present. Please file a bug..

But as far as I tried, the app continued working and the message seemed not causing severe damage to the app.
I'm not sure, but this message may be ignored as a sort of log noise. Or have you experienced something critical with your app?

(Some older report with Unable to present. Please file a bug. said that the subviews closed immediately after the message without touching cancel, I think this is not the case as yours.)

When I find something useful about this issue, I will share it.


By the way, you have mistakenly marked my previous reply as the solution, which I believe is not.
As you have noticed, you cannot unmark it (one bad thing with this site).

Unfortunately, SOLVED threads would not be appealing and get less attention from readers.
In case you have something critical which needs to be fixed, you should better start a new thread.
(Please be careful not to mark it as SOLVED mistakenly.)

You should use the Code block (icon <>) when you show some code, easily readable would also affect involving more readers into this issue.

Hello,
Thank you for your reply....... No I don't have a critical problem with my app. I just find that the messages in the log are annoying. I see that I did mark it as solved unintentionally though. At least you can duplicate my issue. I also understand Apple improving the product, but don't understand the reason for the error. Which disappears if you pair the parent down to two navigation links only...
Sigh...
Thanks again,
Bob
I am having the exact same issue. I have a NavigationLink within a LazyVGrid, and the child view will appear before going back to the parent view... This only happens when I have only 1 item in the list.
Navigation Link - presentationMode.Dismiss problem XCode 12.5
 
 
Q