转载请注明出处:https://www.jianshu.com/p/e80980a02060 古道西风瘦啥
环境:unity 2018.2.7f1、xcode 11.2。
升级xcode11后,用unity导出ios工程编译报错UnityMetalSupport Duplicate interface definition for class 'CAMetalLayer'。
原因是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