1

我有以下代码可以在 Xcode 9.2 标准构建系统中编译和运行,但是在使用或构建项目时swift build -c release它不会编译并给出abort trap: 6New Build System (Preview)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")
}

感谢您提前提供帮助。

4

1 回答 1

1

显然,这是构建系统在 Xcode 中混淆了区分大小写的文件命名的问题。Account.swift在同一个模块中包含和之类的文件account.swift会导致错误。

于 2018-06-11T13:28:41.917 回答