George Green George Green - 6 months ago 85
iOS Question

UIView/UICoordinateSpace convert rect/point clash in swift 3

So I've recently had to convert my project to Swift 3, and while a bit of a pain, it has mostly gone ok. However I am now down to one final set of errors that I can't work out!

Im using

self.convert(point, to: v)

to convert a point between views, but Xcode keeps giving me build errors saying that

'convert(_:to:)' is only available on iOS 8.0 or newer

This seems to be due to the method definition

public protocol UICoordinateSpace : NSObjectProtocol {

@available(iOS 8.0, *)
public func convert(_ point: CGPoint, to coordinateSpace: UICoordinateSpace) -> CGPoint



clashing with the normal UIView one

extension UIView {


open func convert(_ point: CGPoint, to view: UIView?) -> CGPoint



I can't for the life of me work out how to resolve this! Has anyone come across this or have any idea how to fix it?!


You can manually set the iOS Deployment Target to 7.0, and Xcode builds the app as targeted to 7.0. (I don't know apps built with that manner can be approved for App Store.)

So, you can test that behaviour with your Xcode 8.

And you can silence Xcode with this:

 self.convert(point, to: v as UIView?)

With new renaming rule of Swift 3, some imported methods may have the same signature in Swift, and I'm afraid some of them may not have this sort of workaround, and may not be solved by changing target version.