Swift 3 NSLayoutConstraint.constraints(withVisualFormat:…) throws non-helpful runtime exception
| Originator: | gorman.jan | ||
| Number: | rdar://28365175 | Date Originated: | 2016-09-19 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Version 8.0 (8A218a) |
| Classification: | Other Bug | Reproducible: | Always |
Summary: Due to the removal of implicitly unwrapped optionals in Swift 3, setting up NSLayoutConstraints with visual format is now more annoying and throws an extremely unhelpful error message at runtime: -[_SwiftValue nsli_superitem]: unrecognized selector sent to instance … Steps to Reproduce: See the attached sample project. Change the constraints of a view that is setup view @IBOutlet in a Swift class. Setup your views parameter passed to NSLayoutConstraint.constraints(withVisualFormat:options:metrics:views:) without any type annotation. Run the project and watch it crash Expected Results: Ideally of course this would just work the way it always has but I assume that this will be tricky to do with the removal of implicitly unwrapped optionals. The error message could be much more helpful however, it is absolutely not obvious what this has to do with an unrecognised selector or what a _SwiftValue nsli_superitem is Actual Results: It crashes at runtime. Version: Version 8.0 (8A218a)
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!