0

I need to add a .mlmodel file to my Unit Tests in order to check programmatic model compilation in my framework. But, since version 12, Xcode automatically compiles any .mlmodel file added to the project and replaces it with .mlmodelc which is unwanted in this context.

So, if I add a TestModel.mlmodel to the project, I can't get a resource URL:

NSBundle *bundle = [NSBundle bundleForClass:ModelTest.class];

// modelURL is nil
NSURL *modelURL = [bundle URLForResource:@"TestModel" 
                           withExtension:@"mlmodel"];

If I open the compiled bundle package I can see TestModel.mlmodelc there.

How can I disable automatic CoreML model compilation in Xcode?

4

1 回答 1

0

Project navigator中选择项目后,所有编译的文件都可以在Build Phases选项卡的 Compile Source 部分中找到。你能找到那里的文件吗?如果是,您可以将其删除。

Project navigator中选择文件后,您可以从File Inspector的Target Membership部分执行相同操作 :如果选中目标名称旁边的框,请取消选中它。

最后,如果您希望将此文件添加到应用程序的资源中,您可能必须将其添加到 Build Phase 选项卡的Copy Bundle Resource部分(或者您可以为其创建特定的 Copy File Phase)

于 2020-10-11T09:36:29.433 回答