# If #available check failing

**URL:** <https://forums.swift.org/t/if-available-check-failing/64938>\
**Category:** Using Swift\
**Created:** [May 11, 2023, 3:32pm UTC](https://forums.swift.org/t/if-available-check-failing/64938 "2023-05-11T15:32:46Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tshortli](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tshortli/32/15850_2.png) [@tshortli](https://forums.swift.org/u/tshortli)\
**Post date:** [May 11, 2023, 4:00pm UTC](https://forums.swift.org/t/if-available-check-failing/64938/2 "2023-05-11T16:00:23Z")

</div>

> I had thought that the check worked like Objective C's "respondsToSelector" which would work regardless of the build / target sdk. But it seems like #available does not guard against building with an sdk version where those symbols don't exist. ie it's a run-time vs. a build time check.

Yes, `if #available` is only a runtime check; it doesn't change the fact that the compiler still needs to type check the code inside the then block. When building against the 16.2 SDK, there's no property declaration that the compiler can use to understand how to compile the statement `self.isInspectable = true`. Even in Objective-C, a `respondsToSelector` check wouldn't work on its own; you would also have to forward declare the `isInspectable` property in your project so that the compiler has a definition of the selector for the getter. There is no equivalent to forward declaration in Swift (at least for arbitrary kinds of declarations).

There have been some previous [discussions](https://forums.swift.org/t/build-time-sdk-availability-check/59679) of language features that could be added to Swift to address this problem, mostly revolving around allowing developers to conditionalize code at build time based on either the version of the SDK or the version of a specific module.

---

_[View the full topic](https://forums.swift.org/t/if-available-check-failing/64938)._
