Xcode 7.1.1: Swift literals should be supported in regular code, not just Playgrounds

Originator:igeek1
Number:rdar://23650129 Date Originated:23-Nov-2015 02:29 PM
Status:Closed Resolved:16-Jun-2016 08:25 PM
Product:Developer Tools Product Version:Xcode 7.1.1 (7B1005)
Classification:Enhancement Reproducible:Always
 
Summary:
Swift literals should be supported in regular code, not just Playgrounds.

Steps to Reproduce:
1. Open the attached sample project. It’s a blank iOS single-view application, to which I’ve added a playground called Colors.playground. I then went into the Finder, did Show Package Contents on Colors.playground, and added its Contents.swift directly to the project. In Colors.playground, I’ve defined some color constants by using Xcode 7’s color literals.
2. Open ViewController.swift. Go to line 15:

view.tintColor = Colors.highlight

3. Wonder how Colors.highlight is defined, so Command-click on it.

Expected Results:
We jump to Colors.playground with the definition of “highlight” selected.

Actual Results:
We jump to the separately-embedded Contents.swift file. This would be fine, except that Xcode doesn’t render color literals for this file, so it looks like this:

import UIKit

struct Colors {
    static let primary = [#Color(colorLiteralRed: 0.8980391025543213, green: 0.2588234841823578, blue: 0.2392156571149826, alpha: 1)#]
    static let highlight = [#Color(colorLiteralRed: 0.1461514979600906, green: 0.5412336587905884, blue: 0.8481889367103577, alpha: 1)#]
    static let secondary = [#Color(colorLiteralRed: 0.2570003867149353, green: 0.2734180986881256, blue: 0.3004217445850372, alpha: 1)#]
}

Xcode should either be smart enough to jump to the playground version, or allow color literals to exist in non-Playground files so that we can use them in our normal Colors.swift files, without having to use a playground.

Notes:
Reference: this tweet: https://twitter.com/aligatr/status/667777925727592448
Sample project also posted at http://cl.ly/dtb6

Comments

Resolved in Xcode 8 🎉 This issue has been verified as resolved and can be closed.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!