Abort trap: 6 in protocol extension with typealias definitions

155 Views Asked by At

I have the following code that compiles and runs in Xcode 9.2 Standard Build System and swift build -c release but it does not compile and gives abort trap: 6 when build project with New Build System (Preview) or swift build

import Foundation

protocol RestProtocol {
    associatedtype PostModelType: Codable
    associatedtype GetModelType: Codable
    associatedtype PostResponseType: Codable
}

extension RestProtocol {
    static func consume(with: [String: Any],
                        completion: @escaping (GetModelType?, Error?) -> Void) {
        completion(nil, nil)
    }

    static func produce(with: PostModelType,
                        completion: @escaping (PostResponseType?, Error?) -> Void) {
        completion(nil, nil)
    }
}

struct Model<T: Codable>: Codable {
    var code: Int?
    var message: String?
    var success: Bool?
    var result: T?
}

struct Service: RestProtocol {
    typealias PostModelType = DetailsModel
    typealias GetModelType = Model<DetailsModel>
    typealias PostResponseType = Model<DetailsModel>
}

struct DetailsModel: Codable {
    var response: String?
}

Service.consume(with: ["Key": "value"]) { (response, error) in
    print("This compiles in Xcode and swift build -c release but gives Abort trap: 6 in swift build")
}

Thanks for the helps in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

Apparently this was an issue in build system messing up with case sensitive file naming in Xcode. Having files such as Account.swift and account.swift in the same module would cause the error.