Xcode 10.2 Stuck in Building Some Swift Files

Hi, Community.
I have upgrade Xcode to 10.2 and found my project stuck in building a Swift file forever.
This issue can be easily reproduced with following file:

import Foundation

// Types
struct Foo: Codable {}
struct Bar: Codable {}

// MARK:

struct ItemEnvelope<Element> {
    let items: [Element]
}

extension ItemEnvelope: Codable where Element: Codable {
    enum CodingKeys: String, CodingKey {
        case items = "list"
    }
}

class CodableGeneric: Runnable {
    static func run() {
        let fooEnvelope = ItemEnvelope(items: [Foo()])
        let barEnvelope = ItemEnvelope(items: [Bar()])

        let encoder = JSONEncoder()
        let encodedHello = try! encoder.encode(fooEnvelope)
        let encodedHi = try! encoder.encode(barEnvelope)
        print(fooEnvelope, barEnvelope)
    }
}

The build was success if this file is removed or commented. During the building, Xcode doesn't provide any error information, it just stuck.
Any help is welcomed.

1 Like
extension ItemEnvelope: Codable where Element: Codable {
// This stuck in compiling
//    enum CodingKeys: String, CodingKey {
//        case items = "list"
//    }
}
// workaround
struct ItemEnvelope<Element> {
    let items: [Element]
    enum CodingKeys: String, CodingKey {
        case items = "list"
    }
}

I think you should file a bug.

1 Like

Thanks for replying. I did filed a bug.

I did filed a bug.

Thanks. What was the bug number?

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

@eskimo
The problem ID is 49371608.

Fixed in Xcode 10.2.1

Terms of Service

Privacy Policy

Cookie Policy