美文网首页
#ifdef和@available混用

#ifdef和@available混用

作者: 夜雨聲煩_ | 来源:发表于2021-04-16 13:46 被阅读0次

    解决同时Xcode 10.3(iOS 12.4)和Xcode 11(iOS 13.0)中使用

    #ifdef __IPHONE_13_0
    if (@available(iOS 13.0, *)) {
        if([getMetalDevice() supportsFamily:MTLGPUFamilyApple3])
            pixelFormat = MTLPixelFormatBGRA10_XR;
        else
    #else
    {
    #endif
            pixelFormat =  MTLPixelFormatBGRA8Unorm;
    }
    
    + (PHAuthorizationStatus)authorizationStatus {
        PHAuthorizationStatus status;
    #ifdef __IPHONE_14_0
        if (@available(iOS 14, *)) {
            status = [PHPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite];
    #else
        if(NO) {
    #endif
        }else {
            status = [PHPhotoLibrary authorizationStatus];
        }
        return status;
    }
    

    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.

    相关文章

      网友评论

          本文标题:#ifdef和@available混用

          本文链接:https://www.haomeiwen.com/subject/fcrelltx.html