Xcode editor dies on specific Swift-for-iOS line of code

Originator:vdhamer
Number:rdar://27266049 Date Originated:10-Jul-2016
Status:Duplicate/24260533 Resolved:
Product:XCode Product Version:7.3.1
Classification: Reproducible:Yes
 
Summary:
Context: Xcode 7.3.1, Swift app development for iOS, small app project involving Parse for storage and Facebook for login.
(case a) segmentation fault 11 when the project is loaded, see screenshot.
(case b) after some minor source changes, uncommenting one particular source line - see screenshots - causes the editor to cycle between showing the source file in black and white, and in color. Presumably the incremental compilation fails, and apparently there is a watchdog timer that triggers a retry, which also fails. And this is shown to the user deliberately/accidentally as clearing all syntax highlighting.

Steps to Reproduce:
Case a:
1. Open Xcode 7.3.1
2. Load (case a) project
3. gets segmentation fault within Xcode immediately (screenshot)
Case b:
1. Open Xcode 7.3.1
2. Load (case b) project
3. uncomment line 86 of ContactsTableViewController.swift
4. get cycling between black-and-white and color (2 screenshots)

Expected Results:
Normal ability to edit and debug my project.

Actual Results:
Case a. Segmentation fault within Xcode (without running my own code)
Case b. "An internal error occurred. Source editor functionality is limited. Attempting to restore.." and associated cycling.

Version:
Xcode 7.3.1 (7D1014)
OS X 10.11.5 (everything should be perfectly up to date).
I also have Xcode 8.0 beta (8S128d) installed, but avoid mixing stuff.

Notes:


Configuration:
In case (b), uncommenting one line of code repeatably triggers the problem. Whether a device is attached for debugging, has no impact.

Attachments:
'Screen Shot case b_1.jpg', 'Tinderoid case a.zip', 'Tinderoid case b.zip', 'Screen Shot case a.jpg' and 'Screen Shot case b_2.jpg' were successfully uploaded.

=============================


I found a workaround by being more explicit on typing. I suspect the compiler was trying to deal with something ambiguous or even wrongly typed, and then couldn't figure it out.

I fixed the method with the problem as follows:

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
        
        let myRow: Int = indexPath.row
        let myUser: PFUser = usersLikedAndLinking[myRow] as! PFUser
        let myLabel = myUser["name"] as! String
        cell.textLabel?.text = myLabel

        return cell
    }

But it remains a nasty bug if Xcode crashes on syntax highlighting. Even if it the developer provides less than perfect code.

Comments


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!