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

前端之家收集整理的这篇文章主要介绍了核心数据 – 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相关文章