Ghost Complile Error and other odd project issues

In my project I had made the following code block I changed //ToolbarItemGroup(placement: .topBarTrailing) to ToolbarItemGroup(placement: .topBarLeading) because I got a compile error. Then I started having the effect of everytime I did a Clean then Rebuild I would get the following Error

/Users/barrywest/Desktop/Apple Development/AppleTutorials/APAJSONReader/APAJSONReader/View/SchemaMaintenance/SchemaDetail.swift:149:42 'navigationBarTrailing' is unavailable in macOS

once clicked it would hightlight the commeted out code. then the error would magically go away after clicking on the error

If you do not click the error it would stay, even if you ran the code it would display but the simulator would run instead of getting an error

I then delete the comment, but I still get the ghost complile error with the same effect.

I continued to make changes, and now the I get a different older display on the simulator, as compared to my Preivew Display. The colors seem to have gotten saved in the Run Simulator, even after Clean Build, Recompile...

I still get the ghost error which has been removed and the new Executable still contains ghost code which shows incorrect colors.

I can have the simulator and preview view running at the same time with different View Colors...

I have closed the project and reopend the project with no Changes.

My guess is some kind of file corruption somewhere ...


import SwiftUI
import SwiftData

struct SchemaDetail: View {
    @Environment(\.modelContext) var dbContext

...

   var body: some View {
        VStack {
            
            
            switch schemaName {
                
                case .leagues:
                switch displayCategory {
                case .full:
                    leagueFullDisplay
                case .brief:
                    leagueBriefDisplay
                case .edit:
                    leagueEdit
                case .create:
                    leagueCreate
                }

...

 }
            //Text(schemaName.localizedName)
        }
        .navigationTitle(schemaName.localizedName)
        .toolbar {
           ** //ToolbarItemGroup(placement: .topBarTrailing)**
           ToolbarItemGroup(placement: .topBarLeading)
            {
                switch displayCategory {
                case .full:
                    Button(action: {

                    }, label: {
                        Image(systemName: "minus.magnifyingglass")
                    })
                    Button(action: {

                    }, label: {
                        Image(systemName: "doc.badge.plus")
                    })
                    Button(action: {
                        // Preload from json  Warning may be about using background thread ???
                        Task(priority: .background) {
                            loadLeagues()
                        }
                    }, label: {
                        Image(systemName: "folder.fill.badge.gearshape")
                    })
                    
                case .brief:
                    Button(action: {

                    }, label: {
                        Image(systemName: "plus.magnifyingglass")
                    })
                    Button(action: {

                    }, label: {
                        Image(systemName: "doc.badge.plus")
                    })
                case .create:
                    Button(action: {

                    }, label: {
                        Image(systemName: "square.and.arrow.down.fill")
                    })
                    Button(action: {

                    }, label: {
                        Image(systemName: "arrowshape.turn.up.backward.circle.fill")
                    })
                case .edit:
                    Button(action: {

                    }, label: {
                        Image(systemName: "square.and.arrow.down.fill")
                    })
                    Button(action: {

                    }, label: {
                        Image(systemName: "arrowshape.turn.up.backward.circle.fill")
                    })
                }
            }
        }
    }
        
}

#Preview {
    SchemaDetail(schemaName: LeagueCategory.sessions, displayCategory: DisplayCategory.brief)
}
Answered by bxw0405 in 800145022

I found that the difference in the Simulator View vs Preview is different in the recreated App also. I am using a Color Extension which may be reason. I will have to look at that also.

Rebooting my Mac got rid of the ghost Error Message. I am assuming that it is some kind of cache issue. Restarting XCode did not resolve, so maybe the mac was caching the file

Still have the issue with the Preview IPad NavigationSplitView having different colors than in my Preview Window.

Here is the Code Segement

    var body: some View {
        NavigationSplitView(columnVisibility: .constant(.doubleColumn)) {
            VStack {
                Form {
                    Section(header: Text("Admin Matainence").foregroundStyle(Color.theme.red).font(.subheadline)){
                        List {
                            NavigationLink("Leagues", destination: SchemaDetail(schemaName: LeagueCategory.leagues, displayCategory: DisplayCategory.full))
                            NavigationLink("Sessions", destination: SchemaDetail(schemaName: LeagueCategory.sessions, displayCategory: DisplayCategory.full))
                            NavigationLink("Format", destination: SchemaDetail(schemaName: LeagueCategory.formats, displayCategory: DisplayCategory.full))
                            NavigationLink("Divisions", destination: SchemaDetail(schemaName: LeagueCategory.divisions, displayCategory: DisplayCategory.full))
                            NavigationLink("Teams", destination: SchemaDetail(schemaName: LeagueCategory.teams, displayCategory: DisplayCategory.full))
                            NavigationLink("Players", destination: SchemaDetail(schemaName: LeagueCategory.players, displayCategory: DisplayCategory.full))
                            NavigationLink("Match", destination: SchemaDetail(schemaName: LeagueCategory.matches, displayCategory: DisplayCategory.full))
                            NavigationLink("Game", destination: SchemaDetail(schemaName: LeagueCategory.games, displayCategory: DisplayCategory.full))
                            NavigationLink("Score Sheet", destination: SchemaDetail(schemaName: LeagueCategory.scoreSheets, displayCategory: DisplayCategory.full))
                            NavigationLink("Test Data", destination: DivisionSessionTeamsTournamentsView())
                        }
                        
                    }
                    //.backgroundColor(.gray)
                }
                //.foregroundColor(.theme.accent)

            }
            .navigationTitle("Wildcards Admin")
            .padding()
            //.background(Color.theme.background)

        } detail: {

            
        }
        // Balanced Style keep sidebar open
        .navigationSplitViewStyle(.balanced)
        
    }

    
}


#Preview {
    ContentView()
        .environment(ApplicationData())
}

so on the simulator the List Row Background is red on the preview it is a gray color.

The Toolbar in both the simulator and preview have the red color on the toolbar icons.

If I do not get a response by Friday, I will have to just live with it. I am closing this issue, as I am new to working with the NavigationSplitView on the Mac.

In my investigation, I recreated a new Project and moved all the files to the new Project. The issues went away...

I seem to have this type of issue occasionally.... This is frustrating to have to recreate projects

I have also had the issue where I had a file like Something.swift cause an error where the compiler reported duplication file name in my Library Folder ... ? I delete it, but I wished I had saved the error message.....

Accepted Answer

I found that the difference in the Simulator View vs Preview is different in the recreated App also. I am using a Color Extension which may be reason. I will have to look at that also.

Rebooting my Mac got rid of the ghost Error Message. I am assuming that it is some kind of cache issue. Restarting XCode did not resolve, so maybe the mac was caching the file

Still have the issue with the Preview IPad NavigationSplitView having different colors than in my Preview Window.

Here is the Code Segement

    var body: some View {
        NavigationSplitView(columnVisibility: .constant(.doubleColumn)) {
            VStack {
                Form {
                    Section(header: Text("Admin Matainence").foregroundStyle(Color.theme.red).font(.subheadline)){
                        List {
                            NavigationLink("Leagues", destination: SchemaDetail(schemaName: LeagueCategory.leagues, displayCategory: DisplayCategory.full))
                            NavigationLink("Sessions", destination: SchemaDetail(schemaName: LeagueCategory.sessions, displayCategory: DisplayCategory.full))
                            NavigationLink("Format", destination: SchemaDetail(schemaName: LeagueCategory.formats, displayCategory: DisplayCategory.full))
                            NavigationLink("Divisions", destination: SchemaDetail(schemaName: LeagueCategory.divisions, displayCategory: DisplayCategory.full))
                            NavigationLink("Teams", destination: SchemaDetail(schemaName: LeagueCategory.teams, displayCategory: DisplayCategory.full))
                            NavigationLink("Players", destination: SchemaDetail(schemaName: LeagueCategory.players, displayCategory: DisplayCategory.full))
                            NavigationLink("Match", destination: SchemaDetail(schemaName: LeagueCategory.matches, displayCategory: DisplayCategory.full))
                            NavigationLink("Game", destination: SchemaDetail(schemaName: LeagueCategory.games, displayCategory: DisplayCategory.full))
                            NavigationLink("Score Sheet", destination: SchemaDetail(schemaName: LeagueCategory.scoreSheets, displayCategory: DisplayCategory.full))
                            NavigationLink("Test Data", destination: DivisionSessionTeamsTournamentsView())
                        }
                        
                    }
                    //.backgroundColor(.gray)
                }
                //.foregroundColor(.theme.accent)

            }
            .navigationTitle("Wildcards Admin")
            .padding()
            //.background(Color.theme.background)

        } detail: {

            
        }
        // Balanced Style keep sidebar open
        .navigationSplitViewStyle(.balanced)
        
    }

    
}


#Preview {
    ContentView()
        .environment(ApplicationData())
}

so on the simulator the List Row Background is red on the preview it is a gray color.

The Toolbar in both the simulator and preview have the red color on the toolbar icons.

If I do not get a response by Friday, I will have to just live with it. I am closing this issue, as I am new to working with the NavigationSplitView on the Mac.

Ghost Complile Error and other odd project issues
 
 
Q