Not able to add .containerRelativeFrame in my SwiftUI code

140 Views Asked by At

When I'm trying to add .containerRelativeFrame in my SwiftUI code but getting errors :

Like this, I'm getting errors :

  1. Value of type 'some View' has no member 'containerRelativeFrame'
  2. Reference to member 'horizontal' cannot be resolved without a contextual type
  3. Reference to member 'vertical' cannot be resolved without a contextual type

--How to resolve this--

This is the code.

1

There are 1 best solutions below

0
On

This API is only available starting from iOS 17.

  1. Make sure you use latest Xcode (Xcode 15).
  2. Add @available(iOS 17, *) above your struct definition:
@available(iOS 17, *)
struct FeedView: View {
    ...
}