xcode11 unity UnityMetalSupport Duplicate interface definition for class 'CAMetalLayer'的解决方法

转载请注明出处:https://www.jianshu.com/p/e80980a02060 古道西风瘦啥

环境:unity 2018.2.7f1、xcode 11.2。

升级xcode11后,用unity导出ios工程编译报错UnityMetalSupport Duplicate interface definition for class 'CAMetalLayer'。

image.png

原因是unity UnityMetalSupport中的CAMetalLayer与ios中QuartzCore的CAMetalLayer重名了。

在unity没有官方修复前,先自己动手解决吧!

可以考虑使用OC语言的category特性巧妙解决,代码如下:

@interface CAMetalLayer (category)
@property (readwrite) BOOL framebufferOnly;
@property (readwrite) CGSize drawableSize;
@property BOOL presentsWithTransaction;
@property (readwrite, retain) id<MTLDevice> device;
@property (readwrite) MTLPixelFormat pixelFormat;
@property (readonly) id<MTLTexture> texture;

- (id<CAMetalDrawable>)newDrawable;
- (id<CAMetalDrawable>)nextDrawable;
@end
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。