Catalyst的ML构建错误(Xcode 12 GM) [英] ML Build error for Catalyst (Xcode 12 GM)

查看:66
本文介绍了Catalyst的ML构建错误(Xcode 12 GM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有其他人对带有ML模型的GM版本有疑问,并且对此有解决方案吗?我收到以下错误:

Anyone else having issues with the GM release with ML models and has a solution for this? I get the following error:

Type 'MLModel' has no member '__loadContents'

我已经清理了Project +删除的派生数据(这是一个生成的文件,放在派生数据文件夹中)

I have cleaned the Project + deleted derived data (this is a generated file that is put into the derived data folder)

我注意到该方法不适用于我使用的mac OS 10.15,但是由于某种原因而存在.

I notice that the method should not be there for mac OS 10.15 which I use, but it there for some reason.

我还注意到,当GM是量产版本时,此API仍处于beta版吗? https://developer.apple.com/documentation/coreml/mlmodel

I also noticed that this API is still in beta while the GM is a production build? https://developer.apple.com/documentation/coreml/mlmodel

我应该重新生成ML模型吗?

Should I regenerate the ML model?

推荐答案

根本原因是:

Xcode 12.0 GM中的

CoreML编译器正在生成仅具有在macOS BigSur上可用的符号的代码,从而导致编译问题.如果目标是使用Xcode 12.0构建催化剂或仅限macOS的应用程序

CoreML compiler in Xcode 12.0 GM is generating code that has symbols available only on macOS BigSur causing the compilation issue. If the goal is to build a catalyst or macOS-only app with Xcode 12.0

修复步骤:

  1. 在目标构建设置中,您可以将COREML_CODEGEN_LANGUAGE设置为无"
  2. 打开终端,然后转到您的.mlmodel文件夹
  3. 键入"xcrun coremlcompiler生成< YourModel.mlmodel>" --language Swift."
  4. 这将创建< YourModel.swift>文件放在同一文件夹中.
  5. 打开Xcode并添加< YourModel.swift>在您的项目中.
  6. 点击< YourModel.swift>并注释掉编译器抱怨的方法.

就我而言,我将其注释掉:

In my case I comment out :

class func load(contentsOf modelURL: URL, configuration: MLModelConfiguration = MLModelConfiguration(), completionHandler handler: @escaping (Swift.Result<Nudity, Error>) -> Void)

class func load(configuration: MLModelConfiguration = MLModelConfiguration(), completionHandler handler: @escaping (Swift.Result<Nudity, Error>) -> Void)

修复快速文件的方法.

这篇关于Catalyst的ML构建错误(Xcode 12 GM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆