xcode9.2swift3.2

Type 'UILayoutPriority' has no member 'defaultHigh'


When using this code in our app, we run into an error:

let value = UILayoutPriority.defaultHigh // Error: Type 'UILayoutPriority' has no member 'defaultHigh'. 

which is super wired because according to the documentation, it is obviously there. And also, if we click through UILayoutPriority and jump to its definition, we see it there as well.

UIKit > NSLayoutConstraint:

extension UILayoutPriority {

    @available(iOS 6.0, *)
    public static let required: UILayoutPriority

So why we cannot use UILayoutPriority.defaultHigh?


Solution

  • It turns out that we need to use UILayoutPriorityDefaultHigh since our code base is still using Swift 3.2. The source code for iOS UIKit is in Swift 4, that's why it is super confusing for us. In Swift 4 and after, we'll use UILayoutPriority.defaultHigh.

    Need to spend the time and do the migration soon!