others-how to solve 'Enum cases with associated values cannot be marked potentially unavailable with '@available'' problem?

1. Purpose

In this post, I would demonstrate how to solve ‘Enum cases with associated values cannot be marked potentially unavailable with ‘@available’’ problem.



2. Solution

  • 2.1 Comment the code that contains @available annotation that cause the problem
  • 2.2 Build the project
  • 2.3 When the error happens, move your mouse to the problem, and click ‘fix’ in the popup window in xcode
  • 2.4 Build the project again

Some useful comments on this:

This is intentional. The ABI of enum cases with payloads that are potentially unavailable is not well-defined. That this worked in the past was by coincidence of your application not requiring the (potentially unavailable) type metadata for the payload. Please either increase your deployment target or mark Foo itself as available as the least-available case



3. Summary

In this post, I demonstrated how to solve ‘Enum cases with associated values cannot be marked potentially unavailable with ‘@available’’ problem, The key point is to use the recommended way to fix the problem in xcode. That’s it, thanks for your reading.