Lister sample project - build errors with the Swif

2019-09-06 06:26发布

问题:

I downloaded the Lister "Productivity App" (Version 1.4, 2014-10-16) sample project from Apple:

https://developer.apple.com/library/ios/samplecode/Lister/Introduction/Intro.html#//apple_ref/doc/uid/TP40014701

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:

  1. /Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/ListerKit/ListDocument.swift:61:114: 'List.Color' does not have a member named 'rawValue'

  2. /Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/ListerKit/ListUtilities.swift:103:31: Bound value in a conditional binding must be of Optional type

  3. /Users/ben/Downloads/ListerAProductivityAppObj-CandSwift/Swift/Common/List.swift:126:22: 'List.Color' cannot be constructed because it has no accessible initializers

  4. /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.

回答1:

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



标签: ios xcode swift