How to fix “Method does not override” when subclassing UIGestureRecognizer
So I tried to create an UI Element in Swift that responds to a specific Gesture. Easy enough let’s look up how that works. The almighty Internet has answers for everything:
Subclass UIGestureRecognizer and override the methods touchesBegan
, touchesMoved
and touchesEnded
.

Okay, I can do that – but wait, what?
It seems like the most recent version of Swift is missing some public
declarations for those override-able methods. Probably because access control has just landed for Xcode/Swift the other day. At least Jared Sinclair supports this theory.
He also offers a Solution: Import UIGestureRecognizerSubclass.h in your Bridging-Header. I am new to this, how do you do that? Turns out Xcode creates the Bridging-Header file for you if you create an Objective-C file in your project. Due to some back and forth I learned that it unfortunately only does that once. If you ever deleted the file it will not come back. So how do you create it manually?
- Create a new Objective-C Header file and name it
<projectName>-Bridging-Header.h
- Go to your Project Root and then find “Build Settings”
- Scroll all the way down and locate the “Swift Compiler – Code Generation” section
- Insert the path to your header file into the “Objective-C Bridging Header” field (Notice that the file might be in the root folder [like mine] or somewhere else)
- Set “Install Objective-C Compatibility Header” to true

Back to the actual solution. Insert this one line into the header file:
https://gist.github.com/552655716a2016b11566
And voila – it works. Suddenly all the desired Methods are avaiable. Well, that was simple.