问题描述
我从 Apple 下载了 ListerProductivity App"(版本 1.4,2014-10-16)示例项目:
我在 OS X 10.10 (Yosemite) 上运行 Xcode 6.0.1.Objective-C 版本运行良好.Swift 版本在其构建中失败并出现四个错误:
/Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/ListerKit/ListDocument.swift:61:114:List.Color"没有名为rawValue"的成员
/Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/ListerKit/ListUtilities.swift:103:31:条件绑定中的绑定值必须是可选类型
/Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/Common/List.swift:126:22:无法构造List.Color",因为它没有可访问的初始值设定项
/Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/Common/List.swift:131:30:List.Color"没有名为rawValue"的成员
我想知道为什么示例项目不能开箱即用地编译?设置按照 README.md
.
该项目被列为需要 Xcode 6.1 或更高版本.有几件事发生了变化,其中之一是枚举的原始值通过 rawValue
属性获得,而在 6.0.x 中通过 toRaw()
方法获得.>
其他错误很可能是由类似的更改引起的.
所以我建议你下载最新的6.1 GM版本,它在appstore中仍然没有(虽然它被列为很快可用"),所以你必须从iOS/MacOS Dev Center手动下载
>I downloaded the Lister "Productivity App" (Version 1.4, 2014-10-16) sample project from Apple:
I have Xcode 6.0.1 running on OS X 10.10 (Yosemite). The Objective-C version runs great. The Swift version fails in its build with four errors:
/Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/ListerKit/ListDocument.swift:61:114: 'List.Color' does not have a member named 'rawValue'
/Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/ListerKit/ListUtilities.swift:103:31: Bound value in a conditional binding must be of Optional type
/Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/Common/List.swift:126:22: 'List.Color' cannot be constructed because it has no accessible initializers
/Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/Common/List.swift:131:30: 'List.Color' does not have a member named 'rawValue'
I wonder why doesn't the sample project compile out of the box? The setup is as per the README.md
.
The project is listed as requiring Xcode 6.1 or later. A few things have changed, one of them is that raw values from enums are obtained via the rawValue
property, whereas in 6.0.x via the toRaw()
method.
The other errors are most likely caused by similar changes.
So I suggest you to download the latest 6.1 GM version, which is still in not available in the appstore (although it's listed as "available shortly"), so you have to manually download from the iOS/MacOS Dev Center
这篇关于Lister 示例项目 - 使用 Swift 版本构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!