0

I have a very simple ViewModifier but no matter what this error always happen -> Type 'MySSSAJHKDKJLHSADKJASDKJDS' does not conform to protocol 'ViewModifier'

struct MySSSAJHKDKJLHSADKJASDKJDS: ViewModifier {
 func body(content: Content) -> some View {
    return  content.foregroundColor(.cyan)
        .font(.subheadline)
 }
 }
Steven-Carrot
  • 2,368
  • 2
  • 12
  • 37
  • Just curious, why did you name your struct like that? – Kuro Neko Jul 20 '22 at 02:38
  • Does this answer your question? [see why "type does not conform to protocol" in Xcode (swift)](https://stackoverflow.com/questions/36872667/see-why-type-does-not-conform-to-protocol-in-xcode-swift) – Kuro Neko Jul 20 '22 at 02:40
  • i named it weirdly on purpose because there is another answer saying the name may be duplicated. i visited your link also it does not help with my problem. it asked me to add protocol stub but i m having protocol stub already – Steven-Carrot Jul 20 '22 at 02:44
  • What are your Xcode, target, iOS version? – Steven-Carrot Jul 20 '22 at 04:36
  • 1
    Compiled fine here, Xcode 13.4. Look for possible duplication of ViewModifier protocol in your project (naming conflict). – Asperi Jul 20 '22 at 04:51

1 Answers1

2

In my case, I have a file and struct named Content. That conflicts with the body function parameter. Renaming or deleting that file works.

asktao
  • 21
  • 4