Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusing compile error trying to upgrade to Swift 1.2

I've been able to update my code for XCode 6.3 and Swift 1.2 without much issue, until I tried to fix my overridden touch input functions from UIHandler. I updated the signature of all four touch functions to the following:

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
    super.touchesBegan(touches, withEvent: event)
    ...
}

override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
    super.touchesMoved(touches, withEvent: event)
    ...
}
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
    ...
}
override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent) {
    ...
}

XCode's autocomplete actually suggests these methods/signatures when I go to write them, so I know that XCode recognizes Swift 1.2. However, when I clean and build, I get "Method does not override any method from its superclass" for all four functions, as well as similar errors when calling the "super" versions of those functions.

I haven't found anything in project/build settings that stands out, and I tried clearing the DerivedData folder as well as restarting my computer, but I'm still getting these errors.

like image 397
heyx3 Avatar asked Dec 09 '25 19:12

heyx3


2 Answers

So I was hitting the EXACT same error messages as you were, and it was driving me crazy. I finally figured out what the problem was ... and if you had followed the same tutorial online I did, it might have gotten you as well.

Turns out I had a swift file called Set.swift ... that defined a class called Set.

But now in Swift 1.2, they introduced their own class called Set, so my class was causing collisions and these errors whereever I used Set<> (mostly in the touchesXXX part, but there was one other spot in the code where I used Set, and that's what clued me in). So I just went into the Set.swift, and renamed the class to something else, and then it all started compiling correctly.

Hope that helps!

like image 87
user3302800 Avatar answered Dec 11 '25 09:12

user3302800


Did you try completely cleaning the project (CMD + ALT + SHIFT + K)?

I had to do that in mine to get it to compile.

like image 21
Knight0fDragon Avatar answered Dec 11 '25 08:12

Knight0fDragon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!