Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"if (@available(iOS 13.0, *))" doesn't compile in Xcode 10.3

I have such code:

if (@available(iOS 13.0, *)) {
    if([getMetalDevice() supportsFamily:MTLGPUFamilyApple3])
        pixelFormat = MTLPixelFormatBGRA10_XR;
    else
        pixelFormat =  MTLPixelFormatBGRA8Unorm;
}

It works in Xcode 11, but doesn't work in Xcode 10.3. A preprocessor says it doesn't know what is MTLGPUFamilyApple3 (which was introduced in iOS 13).

I tried to use a preprocessor macro:

#define isIOS13 (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_13_0)  

but a preprocessor complains Function-like macro 'floor' is not defined.

The same for

#define isIOS13 (int(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_13_0)

I need to use both Xcode 10.3 ( iOS 12.4 ) and Xcode 11 ( iOS 13.0 ) because of stability reasons.

What can I do to make my code work in both Xcodes?

like image 524
olha Avatar asked Oct 21 '25 01:10

olha


1 Answers

#ifdef __IPHONE_13_0
if (@available(iOS 13.0, *)) {
    if([getMetalDevice() supportsFamily:MTLGPUFamilyApple3])
        pixelFormat = MTLPixelFormatBGRA10_XR;
    else
#else
{
#endif
        pixelFormat =  MTLPixelFormatBGRA8Unorm;
}

But you should use this code only if you provide some opensource library that support several Xcodes.

If this is part of yours project, you should just migrate to new Xcode and doesn't overcomplicate yours code with preprocessor operators.

Better to solve problems with Appium instead of this.

like image 181
Cy-4AH Avatar answered Oct 23 '25 17:10

Cy-4AH