Search code examples
swiftcore-graphicsdeprecated

How to solve this deprecation issue "abs is deprecated: Please use the `abs(_)` free function"


I have a Swift file where I import Foundation and CoreGraphics, but at the place where I call abs(x) where x is a CGFloat, I get this warning:

abs is deprecated: Please use the abs(_) free function

What function should I use?

Thank you


Solution

  • That seems to be a compiler bug, if you are using abs(x) in a static context.

    According to the comments you can work around the warning by using:

    Swift.abs(x)