核心数据 – iOS:由于Xcode 9中的Fetched Indexes,无法编译CoreData模型

根据发行说明,Xcode 9增加了对获取索引的支持:

“The data model editor presents a unified interface for Core Data’s
new fetch indexes feature as well as its existing property index and
entity compound index features. Older data models are translated into
fetch index form for editing,and saved to the old file format when
necessary. Compiling a data model with a Deployment Target lower than
iOS 11,watchOS 4,macOS 10.13,or tvOS 11 continues to generate a
compatible compiled form. (30843153)”

我的项目目前已将部署目标设置为iOS 9,但我无法编译我的CoreData模型,它为每个具有复合索引集的实体提供了以下错误:

Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[0]: error: Expression requires a concrete result type.  
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[0]: error: Expression attributes are not compatible with the current deployment target.  
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[1]: error: Expression requires a concrete result type.  
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[1]: error: Expression attributes are not compatible with the current deployment target.  
Model.xcdatamodeld/Model.xcdatamodel:MyEntity: error: Fetch Indexes feature requires iOS deployment target 11.0 or later  
Model.xcdatamodeld/Model.xcdatamodel:MyEntity: error: Fetch Indexes feature requires Xcode 9.0 tools or later

知道如何修复构建错误吗?

更新:

除了从关系创建的情况外,Xcode 9正确地将复合索引转换为获取索引,如“已知问题”部分所述:

The data model editor only supports creating fetch indexes from attributes and expressions in this beta,not from relationships. (32407895)

受影响的提取索引如下所示,可以从下拉菜单中选择唯一的属性:

但是,文档中没有描述的解决方法.

解决方法

我刚刚在Xcode 9 GM中遇到过这个问题.我观察到的是,在索引编辑器中取消选中Ascending复选框会导致出现此错误(它仅在我创建新索引后显示).我假设只在iOS 11提取索引中支持调整此索引属性(您会注意到您在Xcode 9之前创建的任何索引默认列为升序).

TL; DR:确保在fetch index编辑器中检查所有属性的Ascending复选框.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...