Xcode 11 Beta 4 SwiftUI Deprecations: Can You Help Me Fix:

        .navigationBarItems(trailing:
            // 'PresentationLink' is deprecated: Use .sheet modifier instead.
            PresentationLink(destination: ProfileHost()) {
                Image(systemName: "person.crop.circle")
                    .imageScale(.large)
                    .accessibility(label: Text("User Profile"))
                    .padding()
            }
        )

How to change the about to use .sheet modifier?

            // init(_:minimumDate:maximumDate:displayedComponents:)' is deprecated: DatePicker labels are now required
            DatePicker(
                $profile.goalDate,
                minimumDate: Calendar.current.date(byAdding: .year, value: -1, to: profile.goalDate),
                maximumDate: Calendar.current.date(byAdding: .year, value: 1, to: profile.goalDate),
                displayedComponents: .date
            )

??

var animation: Animation {
// 'spring(mass:stiffness:damping:initialVelocity:)' is deprecated: Use response based spring() or interpolatingSpring() instead
    Animation.spring(initialVelocity: 5)
    	.speed(2)
     	.delay(0.03 * Double(index))
}

Never mind! Apple updated the tutorial with the fixes.

Sorry...

It would be very helpful for others if you could post the answer.

Thank you in advance.

  1. Replace with .sheet():

     // Add these member vars:
     @State var showingProfile = false
     
     var profileButton: some View {
         Button(action: { self.showingProfile.toggle() }) {
             Image(systemName: "person.crop.circle")
                 .imageScale(.large)
                 .accessibility(label: Text("User Profile"))
                 .padding()
         }
     }
     
         // Change to:
             .navigationBarItems(trailing: profileButton)
             .sheet(isPresented: $showingProfile) {
                 ProfileHost()
             }
    
  2. DatePicker:

     // Add member var
     var dateRange: ClosedRange<Date> {
         let min = Calendar.current.date(byAdding: .year, value: -1, to: profile.goalDate)!
         let max = Calendar.current.date(byAdding: .year, value: 1, to: profile.goalDate)!
         return min...max
     }
     
     // Change DatePicker init to:
                 DatePicker(
                     "Goal Date",
                     selection: $profile.goalDate,
                     in: dateRange,
                     displayedComponents: .date)
    
    var animation: Animation {
        Animation.spring(dampingFraction: 0.5)
        	.speed(2)
         	.delay(0.03 * Double(index))
    }
Terms of Service

Privacy Policy

Cookie Policy