Receive error when attempting to use .listStyle() function.

I receive an error when using the .listStyle(.carousel) function in Xcode 12.5, that error being Cannot infer contextual base in reference to member 'carousel' What should I do?

That error depends on other parts of your code. Can you show your code enough to reproduce the issue?

For some reason, I cannot upload an image or link to Imgur.

struct StartView: View {     var workoutTypes: [HKWorkoutActivityType] = [.cycling, .running, .walking, .other]          var body: some View {         List(workoutTypes){ workoutType in             NavigationLink(                 workoutType.name,                 destination: Text(workoutType.name)             )             .padding(EdgeInsets(top: 15, leading: 5, bottom: 15, trailing: 5))         }         .listStyle(.carousel)         .navigationBarTitle("Workouts")     } }

Thanks for showing your code. You may need to use Answers to show additional info well formatted.


I do not have enough time to watch the session video carefully, but your code seems to be taken from the session video or the sample code for the session.

It is intended to be compiled with Swift 5.5/Xcode 13.

Please try changing .listStyle(.carousel) to .listStyle(CarouselListStyle()).

But there may be other parts you need Swift 5.5.

The .listStyle(.carousel) code is used in WWDC19 (SwiftUI on watchOS) as well so it must not require Xcode 13. Replacing it with CarouselListStyle() is what worked for me though. I'm using Xcode 12.5.

Receive error when attempting to use .listStyle() function.
 
 
Q