Debugger guidance

Good morning,
In using “equivalent” code for two lists I obtain an error for a constraint for one of the lists

Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
	(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x6000021aaa80 h=-&- v=--& SwiftUI.UIKitNavigationBar:0x1030af090.minY == 0   (active, names: '|':UILayoutContainerView:0x1030b0d60 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x6000021aae90 h=-&- v=--& SwiftUI.UIKitNavigationBar:0x1030af090.height == 108   (active)>",
    "<NSLayoutConstraint:0x60000219f4d0 V:[SwiftUI.UIKitNavigationBar:0x1030af090]-(0)-[UIFocusContainerGuide:0x600003d0eb20'UINavigationControllerContentFocusContainerGuide']   (active)>",
    "<NSLayoutConstraint:0x60000219f5c0 UIFocusContainerGuide:0x600003d0eb20'UINavigationControllerContentFocusContainerGuide'.bottom == UILayoutContainerView:0x1030b0d60.bottom   (active)>",
    "<NSLayoutConstraint:0x6000021b9db0 'UIView-Encapsulated-Layout-Height' UILayoutContainerView:0x1030b0d60.height == 36   (active)>"
)
Any suggestions as to decipher the error message and identify which  constraint is being referred to.   The code for the lists is provided  as well as the screen
Instrument list - works

type or import SwiftUI
import SwiftData

struct PouchInstrumentList: View {

@Environment(\.modelContext) private var context
var pouch: Pouches
@Query var instruments: [Instrument]
@State private var multiSelection = Set<String>()
@State private var selectedInstruments = [Instrument]()

var body: some View {
    NavigationStack  {
        VStack {
            List (instruments, selection: $multiSelection) { instrument in
                HStack  {
                    Text(instrument.catagory)
                        .frame (
                            maxWidth: .infinity,
                            maxHeight: .infinity,
                            alignment: .leading
                        )
                    Text(instrument.name)
                        .frame (
                            maxWidth: .infinity,
                            maxHeight: .infinity,
                            alignment: .leading
                        )
                 }
             }
            .listStyle(.plain)
            .toolbar {
                ToolbarItem(placement: .navigationBarLeading){
                    if !selectedInstruments.isEmpty {
                        Button {
                            selectedInstruments.removeAll()
                        } label: {
                            Image(systemName: "trash")
                                .backgroundStyle(.red)
                        }
                    }
                }
                ToolbarItem(placement: .navigationBarTrailing) {
                    EditButton()
                }
            }
            Text("\(multiSelection.count) selected")
            
                .onChange( of: multiSelection) { oldValue , newValue  in// new value contains id of selected instruments
                    for value in newValue {                        //loop thru selected values
                        let selectedInstrument = instruments.first(where: { $0.id == value }) // unwrap optional
                        if let selectedInstrument {
                            if !selectedInstruments.contains(selectedInstrument) { // if instrument is not in selected list
                                selectedInstruments.append(selectedInstrument)     // add to list
                            }
                        }
                    }
                }
        }
        
    }
    
}

}

KitList

import SwiftUI
import SwiftData

struct PouchKitList: View {
    
    @Environment(\.modelContext) private var context
    var kit: Kits
    @Query var kits: [Kits]
    @State private var multiSelection = Set<String>()
    @State private var selectedKits = [Kits]()
    
    var body: some View {
        NavigationStack  {
            VStack {
                List (kits, selection: $multiSelection) { kit in
                    HStack  {
                        Text(kit.name)
                            .frame (
                                maxWidth: .infinity,
                                maxHeight: .infinity,
                                alignment: .leading
                            )
                    }
                }
                .listStyle(.plain)
                .toolbar {
                    ToolbarItem(placement: .navigationBarLeading){
                        if !selectedKits.isEmpty {
                            Button {
                                selectedKits.removeAll()
                            } label: {
                                Image(systemName: "trash")
                                    .backgroundStyle(.red)
                            }
                        }
                    }
                    ToolbarItem(placement: .navigationBarTrailing) {
                        EditButton()
                    }
               }
                
                Text("\(multiSelection.count) selected")
                
                .onChange( of: multiSelection) { oldValue , newValue  in// new value contains id of selected instruments
                 for value in newValue {                        //loop thru selected values
                 let selectedKit = kits.first(where: { $0.name == value }) // unwrap optional
                 if let selectedKit {
                     if !selectedKits.contains(selectedKit) { // if kit is not in selected list
                         selectedKits.append(selectedKit)     // add to list
                 }
                }
              }
            }
        }
    }
        
        
        
    }
}
     
![Screenshot 2024-03-24 at 10.02.02 AM|490x500](upload://1QqwaCjsahFUHiU4swOujfGP9T.png)

Thanks 

Joel 

Simulators throw up these constraint messages often in SwiftUI Views. SwiftUI sits on top of UIKit so what happens is that the positioning of Objects in the View are translated into NSLayoutConstraints. As the SwiftUI View gets more complex, it’s likely that the translation results in conflicts which is why you are getting the message in the Console. Ignore the warming’s.

Thanks Chris,
All good , tracked it down to declaring the kit list twice .
All views completed and functional and now just have to reorganize into split navigation.
BTW , is there a way of finding where the SwiftData file(s) are located . I want to test if this sqlite repository can be read (not written) for aggregating /reports
Joel

Yeah you can and it is sqlite3.

What you need to do is set up your project so that it sets SQLDebug on.

  1. Go to the Product menu.
  2. Hold down the Option key.
  3. Click “Run…”
  4. Go to the Arguments tab.
  5. Click + under Arguments Passed on Launch.
  6. Add this in the text field: -com.apple.CoreData.SQLDebug 1
  7. Now click Run to launch your app.

When the App launches on the simulator you will get a lot of details in the Console related to CoreData (SwiftData) which includes the directory path to the default.store file which is the CoreData file. It will look something like this:

"/Users/yourusername/Library/Developer/CoreSimulator/Devices/1AEEA088-5F82-4306-8B46-3939A8331475/data/Containers/Data/Application/5F912D45-7CF8-4FBA-AB64-18C35A0C57C4/Library/Application Support/default.store"

Copy that entire string including the quotes.
Open Terminal and at the prompt type
sqlite3 with a space after it and paste that string and hit return and you will get the sqlite prompt something like this:

SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
sqlite>

Note that the table names and field names are not exactly as you would expect so have a sniff around to make sense of it all.

Type .sch to get the schema listing.

Above all, be careful what you mess with.

thanks again

No worries. Leave that argument there in the Run Arguments and if you want to turn off the logging just uncheck it. Pretty useful really to see what is going on in the background.