gpt4 book ai didi

swift - 中止陷阱 : 6 in protocol extension with typealias definitions

转载 作者:行者123 更新时间:2023-11-28 06:07:18 24 4
gpt4 key购买 nike

我有以下代码在 Xcode 9.2 标准构建系统和 swift build -c release 中编译和运行,但它不编译并给出 abort trap: 6 when使用 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")
}

提前感谢您的帮助。

最佳答案

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

关于swift - 中止陷阱 : 6 in protocol extension with typealias definitions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47837853/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com