Xcode_8.2.1 (8C1002): Extension protocol conformance prevents UIButton event connections in IB

Originator:igeek1
Number:rdar://30001713 Date Originated:12-Jan-2017 05:57 PM
Status:Duplicate of 17023935 Resolved:31-Jan-2017 02:48 AM
Product:Developer Tools Product Version:Xcode_8.2.1 (8C1002)
Classification:Serious Bug Reproducible:Always
 
Summary:
If you make an extension on UIButton that conforms it to a protocol, you’ll no longer be able to connect to that button’s Sent Events outlets, such as Touch Up Inside.

Steps to Reproduce:
You can follow along with the attached project.

1. Create a Single View iPhone application in Swift.
2. Add a button to the main view controller in the storyboard. Observe that, in the Connections Inspector for that button, all the items under Sent Events are available for connection (e.g. Did End On Exit, Editing Changed, etc.).
3. In ViewController.swift, add the following code:

protocol MyProtocol { }
extension UIButton: MyProtocol { }

4. Go back to Interface Builder and click on the button. Observe that the button no longer has any Sent Events available for connection. If you had already assigned one of those events to an IBAction method, the Connections Inspector warns that “‘UIButton’ is no longer a valid event source.” as in the screenshot on this bug: https://github.com/Raizlabs/BonMot/issues/252

Expected Results:
Adding an extension to UIButton that conforms it to a protocol has no bearing on whether you can add actions to it.

Actual Results:
Adding an extension to UIButton that conforms it to a protocol breaks the ability to connect actions to it in Interface Builder.

Regression:
Unknown. Reproduces back to Xcode 7.3.1 (7D1014), the earliest version I have installed on my machine.

Notes:
Sample project also posted here: https://cl.ly/ik9k

Comments

The bug to which this was duped, 17023935, has now been closed.

This was reported as fixed in the Xcode 9 beta 3 release notes: https://download.developer.apple.com/Developer_Tools/Xcode_9_beta_3/Release_Notes_for_Xcode_9_beta_3.pdf

I just checked, and this is still present in Xcode 8.3 beta (8W109m).


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!