Issue with DatePicker in Xcode 14

If anyone else having issues with DatePicker.

struct Date: View {

    @State private var date = Date()

       var body: some View {

           VStack {

               Text("Enter your birthday")

                   .font(.largeTitle)

               DatePicker("Enter your birthday", selection: $date)

           }

       }

   }

[LayoutConstraints] 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:0x600001798d20 h=--& v=--& _UIDatePickerCalendarTimeView:0x1431607a0.height == 0   (active)>",

    "<NSLayoutConstraint:0x60000178eda0 _UIDatePickerCompactTimeLabel:0x143169260.centerY == _UIDatePickerCalendarTimeView:0x1431607a0.centerY - 1   (active)>",

    "<NSLayoutConstraint:0x60000178edf0 V:|-(>=0)-[_UIDatePickerCompactTimeLabel:0x143169260]   (active, names: '|':_UIDatePickerCalendarTimeView:0x1431607a0 )>"

)

Will attempt to recover by breaking constraint 

<NSLayoutConstraint:0x60000178eda0 _UIDatePickerCompactTimeLabel:0x143169260.centerY == _UIDatePickerCalendarTimeView:0x1431607a0.centerY - 1   (active)>

Seems to be a bug in the iOS16 SDK for DatePicker. you can safely ignore it. I can't remember what it was but there is a compiler flag u can set so it reduces the error message down to one line to clean up your console. you can probably find it with a google/stackoverflow/forum search

I can't get DatePicker to work either. with style set to .compact, the screen loads and I can tap on the picker. I can select day/month ok, but if I tap the top-left part of the picker to change year it hangs the app and gives this error. If I set the style to .wheel, it hangs immediately the page loads.

import SwiftUI

struct TestDate: View {
   
  @State private var selectedFilingDate = Date()
   
  var body: some View {
    DatePicker("Date", selection: $selectedFilingDate, displayedComponents: .date)
//                  .datePickerStyle(.wheel)
  }
}

struct TestDate_Previews: PreviewProvider {
  static var previews: some View {
    TestDate()
  }
}
Issue with DatePicker in Xcode 14
 
 
Q