Xcode: Why I need #available(iOS 14.0, *) even if the project iOS Deployment Target is 14.1?

Hi! Apple Developers,

I am trying to simplify the code of a project to support only iOS 14.1 or above, such that I remove the unnecessary logic the checks the iOS versions from the code, as well as the code branches that only works for iOS13.X or earlier. However, even if I changed the project's iOS Development Target to 14.1 (as the screenshot below), Xcode will still return compiling error when I delete some *#available(iOS 14.0, ) logic.

I tried to change the following code

to below, without the #available logic, Xcode will return error saying 'status' is only available in iOS 14.0 or newer.

Some more details:

  • I am using up-to-date Xcode 12
  • the project is integrated with some pods with Cocoapods. I also changed the iOS Deployment Target of the Pods project to 14.1.
  • The project uses the old interface builder for UI, not SwiftUI

What else do I need to do, such that I don't need the #available logic in the code any more?

Thank you!

Answered by Claude31 in 687001022

There are 2 different deployment infos, which can be different :

In Project settings

In Target settings

Can you clarify the iOS version you set in DEPLOYMENT INFO of your app target?

Accepted Answer

There are 2 different deployment infos, which can be different :

In Project settings

In Target settings

Hi Claude31, OOPer,

Thank you for pointing out what I missed. I check the individual targets and found the "iOS Deployment Target". After updating each of them to iOS 14.1, I can delete the unnecessary code now.

Xcode: Why I need #available(iOS 14.0, *) even if the project iOS Deployment Target is 14.1?
 
 
Q