[CIContext initWithOptions:]: unrecognized selector sent to instance 0x170400960 in xcode8

浪子不回头ぞ 提交于 2019-12-05 02:09:29

If you look at the crash report, it seems that Xcode 8 has some issue converting the Swift method CIContext(options: [String : Any]?) to its Objective-C counterpart + (CIContext *)contextWithOptions:(NSDictionary<NSString *,id> *)options;.

Instead it is converted as -[CIContext initWithOptions:] hence the unrecognized selector.

One possible workaround is to declare an Objective-C category like this:

@interface CIContext (Workaround)

+ (CIContext *)yourprefix_contextWithOptions:(NSDictionary<NSString *, id> *)options;

@end

@implementation CIContext (Workaround)

+ (CIContext *)yourprefix_contextWithOptions:(NSDictionary<NSString *, id> *)options {
    return [CIContext contextWithOptions:options];
}

@end

Then import this category in your module bridging header and replace your original CIContext init call with the one from this category.

I imagine this is a compilation issue that can be fixed with an Xcode update. In the meantime, this workaround may be helpful.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!