NEW: Learn to build amazing SwiftUI apps for macOS with my new book! >>

Failed to produce diagnostic for expression; please file a bug report Error

Forums > SwiftUI

Hey y'all. I have an error and I don't know the cause of it. Can you guys help me? The error is:

Failed to produce diagnostic for expression; please file a bug report.

There is my SettingsView swift ui page:

import SwiftUI

struct SettingsView: View {

    @Environment(\.presentationMode) var presentationMode

    var body: some View { // This is where the error shows...
        NavigationView{
            VStack(alignment: .center, spacing: 0){
                Form{

                Section(header: Text("Follow us on Social Media")) {
                    FormRowLinkView(icon: "play.fill", color: Color.red, text: "Youtube", link: "https://www.youtube.com/channel/UCswacy5CsFf_TM2ihFf53MQ")
                    FormRowLinkView(icon: "person.crop.circle.badge.plus", color: Color.blue, text: "Twitter", link: "https://twitter.com/harrinandhaanSN")
                    FormRowLinkView(icon: "person.circle", color: Color.blue, text: "Facebook", link: "https://www.facebook.com/harrinandhaan.sathishnirmala")
                    FormRowLinkView(icon: "camera.circle.fill", color: Color.purple, text: "Instagram", link: "www.instagram.com/real_harrinandhaan_sn")
                    }

                .padding(.vertical, 3)

                    Section(header: Text("About the Application")) {
                        FormRowStaticView(icon: "gear", firstText: "Application", secondText: "SMK.")
                        FormRowStaticView(icon: "checkmark.seal", firstText: "Compatibility", secondText: "iPhone")
                        FormRowStaticView(icon: "keyboard", firstText: "Developer", secondText: "Harrinandhaan SN")
                        FormRowStaticView(icon: "paintbrush", firstText: "Designer", secondText: "Harrinandhaan SN")
                        FormRowStaticView(icon: "flag", firstText: "Version", secondText: "1.0.0")
            }
                    .padding()

                }
                    .listStyle(GroupedListStyle())
                .environment(\.horizontalSizeClass, .regular)

            Text("Copyright Sai Mirras Kitchen.\nHarrinadhaan Sathish Kumaar Nirmala")
                .multilineTextAlignment(.center)
                .font(.footnote)
                .padding(.top, 6)
                .padding(.bottom, 8)
                .foregroundColor(Color.secondary)
        }

            .navigationBarItems(trailing: Button(){
                self.presentationMode.wrappedValue.dismiss()
            }) {
                Image(systemName: "xmark")
            }
            .navigationBarTitle("Settings", displayMode: .inline)
            .background(Color("ColorBackground")).edgesIgnoringSafeArea(.all)
    }
}
}
struct SettingsView_Previews: PreviewProvider {
    static var previews: some View {
        SettingsView()
    }
}

Please help me.

1      

Your navigation button is not correct.

Instead of:

            .navigationBarItems(trailing: Button(){
                self.presentationMode.wrappedValue.dismiss()
            }) {
                Image(systemName: "xmark")
            }

do this:

            .navigationBarItems(trailing: Button {
                self.presentationMode.wrappedValue.dismiss()
            } label: {
                Image(systemName: "xmark")
            })

And, really, you should start using the new toolbar API instead, as navigationBarItems is deprecated. Same with navigationBarTitle; you should be using navigationTitle and navigationBarTitleDisplayMode instead. If you still need to target iOS 13, do an availability check and the use the correct method.

1      

@roosterboy

Thanks!😁

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Spend less time managing in-app purchase infrastructure so you can focus on building your app. RevenueCat gives everything you need to easily implement, manage, and analyze in-app purchases and subscriptions without managing servers or writing backend code.

Get Started

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.