-1

I am adding Combine to my iOS application. To do this, I have updated my create account ViewModel to use Combine rather than my previous implementation. Upon adding Combine to my ViewModel, I was met with an error prompting me to add @available(iOS 13.0, *) to my class. I also must add this attribute to every single VC that uses this ViewModel. My deployment target is iOS 13.0 so I am wondering if this is really necessary. Is there a way I can avoid adding this attribute in each class since I will have no users operating on an iOS version lower than iOS 13.0?

zach2161
  • 113
  • 11
  • 1
    Did you _try_ removing the `available` stuff? If you can compile without it, this was _not_ an error and you're fine. If you can't compile without it, you need it. The compiler knows more than you do. – matt Apr 07 '22 at 14:24

1 Answers1

2

No. You only need to use @available annotation when your deployment target is lower than the minimum OS version required for the API you are using.

So when targeting iOS 13, you don't need @available for Combine.

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • But this doesn't explain why the OP "was met with an error prompting me to add `@available(iOS 13.0, *)`". If the OP's deployment target were really iOS 13, this error would not appear. And if it _is_ an error, the code won't compile, and you've left the OP in the lurch. – matt Apr 07 '22 at 14:25
  • @matt it should not be needed, so if that error was really displayed, the deployment target was not iOS 13. However, without seeing the actual project setup it's impossible to answer that side question – Dávid Pásztor Apr 07 '22 at 14:27
  • That's right, so this answer is premature. The compiler knows more than you and I do. – matt Apr 07 '22 at 14:27