objective-c - How to add uncompiled .mlmodel to Xcode UnitTests bundle
问题描述
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?
解决方案
在Project navigator中选择项目后,所有编译的文件都可以在Build Phases选项卡的 Compile Source 部分中找到。你能找到那里的文件吗?如果是,您可以将其删除。
在Project navigator中选择文件后,您可以从File Inspector的Target Membership部分执行相同操作 :如果选中目标名称旁边的框,请取消选中它。
最后,如果您希望将此文件添加到应用程序的资源中,您可能必须将其添加到 Build Phase 选项卡的Copy Bundle Resource部分(或者您可以为其创建特定的 Copy File Phase)
推荐阅读
- python - Python mysql.connector 在 sql 语句中使用变量
- exception - 如何在 Hive 中故意引发异常
- mysql - Length() 将 \0 计为一个字符
- android - 如何在我的 recyclerview 适配器中将 JSON 日期转换为 Kotlin 中的字符串?
- javascript - 如何将多个嵌套对象发送到 html?
- vue.js - v-img 在 vuetify 中显示 url 而不是图像
- java - 使用 Spring JPA 将 DTO 映射到父实体的特定子类,其中 InheritanceType.TABLE_PER_CLASS
- python-3.x - 在 Python 中使用 GeoJSON
- c++ - ++ 运算符在猜谜游戏中不起作用?
- c++ - C++ qt 应用程序编译在一个文件中