Official reference for "#available" in Swift language?

Hi! In some code and articles online I can see the usages/introductions of using "#available" block to conditionally run code depending on the environment. For example:

if #available(iOS 13, *) {
    // use UICollectionViewCompositionalLayout
} else {
    // show sad face emoji
}

However, I don't exactly know what kind of programming language feature is "#someName" called in Swift. I also wasn't able to find the official reference of "#available" from swift.org.

I can find the reference to "@available" and understand it is an "attribute", and there are many other attributes in Swift with different names. However, what is "#available"? Can anybody tell me whether there is official reference? and what language feature it is classified as?

Thank you!

Answered by OOPer in 686947022

Can anybody tell me whether there is official reference?

I would not say the official documentation of Swift (so called the Swift book) is easy to read, but there actually is.

It is classified into Statements of the doc, maybe because it is only used inside conditional statements.

Accepted Answer

Can anybody tell me whether there is official reference?

I would not say the official documentation of Swift (so called the Swift book) is easy to read, but there actually is.

It is classified into Statements of the doc, maybe because it is only used inside conditional statements.

Official reference for "#available" in Swift language?
 
 
Q