Question posted in Xcode
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
Whether you're new to Xcode or an experienced developer, our archive has everything you need to know about this integrated development environment (IDE). From basic functionalities to advanced features, our archive covers a wide range of Xcode-related questions and answers. Browse our archive now and find solutions to your Xcode questions, and take your app development skills to the next level
2
Answers
The reason is that
clipsToBounds
ships with macOS 14 SDK, which includes Xcode 15. In Xcode below 15, this property is not available, so the compiler cannot find it and throws an error. It’s just a kind of syntax detection.The release note is here.
When you need to support both Xcode 14 and Xcode 15 while also wanting to take advantage of new APIs added in macOS 14.0, you need to make use of the
__MAC_OS_X_VERSION_MAX_ALLOWED
macro.In your specific case you would want:
clipsToBounds
is a weird case since it became public in Xcode 15 but it can now be used with a deployment target back to macOS 10.9.The more general approach, when needing to support an API added in macOS 14.0 and not available at all prior to that, and your app has a deployment target older than macOS 14.0, all while supporting Xcode 14 and 15, then you need something like the following:
Once you stop trying to support Xcode 14 you can remove everything between
#else
and#endif, and remove the
#if,
#else, and
#endif` lines.The downside to this is that if you do have alternate code for older versions of macOS while supporting multiple versions of Xcode, that code gets repeated in two places.
The following resolves the duplicate code issue:
Once you stop trying to support Xcode 14 you can remove the
#if
and#endif
lines.