Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I wrap Objective-C code for visionOS only?

I have the following code in Objective-C:

if (@available(iOS 13.0, tvOS 13.0, *)) {
    indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleLarge;
} else {
    indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
}

But this is producing an error.

'UIActivityIndicatorViewStyleWhiteLarge' is unavailable: not available on xrOS

I think I need that first conditional to get run so it doesn't even try to access UIActivityIndicatorViewStyleWhiteLarge.

But when I change the line to if (@available(iOS 13.0, tvOS 13.0, visionOS 1.0, *)). I get the following error:

Unrecognized platform name visionOS

I also tried changing it to xrOS 1.0 (since I heard that some internal usages had it as xrOS for a while. And while I don't get the second compiler error, it does still say it's unavailable.

Any ideas on how to fix this?

like image 952
Charlie Fish Avatar asked Sep 12 '25 23:09

Charlie Fish


2 Answers

Use TARGET_OS_VISION to distinguish RealityKit only targets:

#if TARGET_OS_VISION

#else

#endif // TARGET_OS_VISION
like image 147
gran_profaci Avatar answered Sep 15 '25 13:09

gran_profaci


Use TARGET_OS_VISION

#if TARGET_OS_VISION

#else

#endif
like image 25
ilkerulusoy Avatar answered Sep 15 '25 14:09

ilkerulusoy