0

XCode 8.3.3 w/ Swift 3

import UIKit

class myview: UIView {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

}

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {

}

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {

}

override func touchesCancelled(_ touches: Set<UITouch>?, with event: UIEvent?) {
    // Don't forget to add "?" after Set<UITouch>
}
}

All four functions are throwing the error: "Cannot specialize non generic type "Set". The same code in beta 6 of Xcode 9 doesn't have the same issue.

Scot Woodyard
  • 69
  • 2
  • 12
  • 1
    Did you make that code using copy-paste? If yes, then try to type those methods manually and see how the XCode will show you possible methods – Woof Aug 21 '17 at 01:57
  • Thank you - I tried that, but same issue. It seems to be specific to the project. If I create a new project, it works as expected. I checked my Swift version - 3.1 . I cant think of a reason why this would be specific to a given project. – Scot Woodyard Aug 21 '17 at 02:39
  • That's very strange. You can also check an API, where those methods are provided. They should not be different, but I would check them too – Woof Aug 21 '17 at 02:43
  • 1
    I can't replicate the issue with the same Xcode and Swift versions. Have you tried cleaning the project through Product -> Clean? That might help. If not, sometimes some of my issues have gone away after clearing the derived data folder. Go to Preferences -> Locations, then copy the derived data folder path, go to finder and locate the directory. Inside, try deleting the folder associated with the specific project. Here's a more detailed answer on how to do that. https://stackoverflow.com/questions/38016143/how-to-delete-derived-data-in-xcode-8 – ymulki Aug 21 '17 at 03:42
  • I cleaned out the build folder and the derived data folder, but that didn't fix the issue. – Scot Woodyard Aug 21 '17 at 18:08

1 Answers1

0

This happens because you've declared your own Set object somewhere else in your project.

I know this because I just spent an hour wondering why I was getting this too.

You should rename your existing Set to something else.

user3015717
  • 226
  • 2
  • 7