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