UIViewController subclass in a project supporting iOS 7.0 - 9.0 can't override traitCollectionDidChange

Originator:ryan.arana
Number:rdar://21804257 Date Originated:7/13/2015
Status: Resolved:
Product:Developer Tools Product Version:Xcode Version 7.0 beta 3 (7A152u)
Classification:Serious Bug Reproducible:Always
 
Summary:
I have a UIViewController subclass that I'm trying to override traitCollectionDidChange(previousTraitCollection:) on and I can't because the compiler tells me that UITraitCollection is only available in iOS 8.0 and above. It gives me a Fix-It which adds the @available attribute to the method but then the compiler gives me an error saying "Overriding 'traitCollectionDidChange' must be as available as declaration it overrides". I believe this is because the UITraitEnvironment protocol has no @available attribute on it in the headers.

Steps to Reproduce:
1. Create a new Swift ios project with a deployment target of 7.0
2. Try to override the traitCollectionDidChange() method of the ViewController:

    @available(iOS 8.0, *)
    override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection)
    }

Expected Results:
I expected to be able to compile and run the application and for the app to be able to respond to traitCollection changes.

Actual Results:
Compiler error: "Overriding 'traitCollectionDidChange' must be as available as declaration it overrides."

Version:
Xcode Version 7.0 beta 3 (7A152u)
OSX 10.10.3

Configuration:
An ios project (Swift 2.0) with a deployment target of 7.0 and base SDK of 9.0

Comments


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!