skip to Main Content

Why I am getting build error from Xcode 12.4 (simulator ios 14.x) for the following code?

    if #available(iOS 15.0, *) {
        myTableView.sectionHeaderTopPadding = 0.0 // error here
    }

The error was,

Value of type ‘UITableView’ has no member ‘sectionHeaderTopPadding’

If ios 15 is not available Xcode is supposed to skip compiling this code. Isnt it?

4

Answers


  1. This won’t build as Xcode 12.4 is shipped with iOS14 and is not aware of the presence of "sectionHeaderTopPadding" in iOS 15. You will have to install Xcode 13 to successfully build this.

    Login or Signup to reply.
  2. Because xCode 12.x supports max iOS 14.x development, so how can your xCode know what is provided in iOS 15.x

    If you are working with a team member and your teammate have xCode 13.x then either you can update your xCode to use the this code, or you can comment this code and then build from your xCode (12.x).

    Login or Signup to reply.
  3. Update your XCODE version to 13

    Login or Signup to reply.
  4. You can make a condition for compilation

    #if compiler(>=5.5)
    if #available(iOS 15.0, *) {
        myTableView.sectionHeaderTopPadding = 0.0
    }
    #endif
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search