We're seeing the following error when trying to init the UP struct by calling UP() anywhere in a unit test.
Is it Swift runtime related?
The exception is: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=10, ads=0x12a500a80)
We see it on the following line:
public var mS: MS = .none
The struct can be created without any issues in a minimal sample test-case, but calling init always fails on Xcode 13.2.1 when testing in a full test suite that tests the offending .framework containing the creation of the struct.
(note in case it matters: 1) the thread sanitizer is disabled to avoid another bug and 2) the scheme for the full app containing the .framework is used to run the unit tests, 3) variable names have been simplified)
import Foundation
public struct ADS: Codable {
public var a1: String?
public var a2: String?
public var c: String?
public var st: String?
public var cnt: String?
public var pC: String?
public var ph: String?
public var phExt: String?
public init(from decoder: Decoder) throws {
// unneeded
}
public init(a1: String? = nil,
a2: String? = nil,
c: String? = nil,
st: String? = nil,
cnt: String? = nil,
pC: String? = nil,
ph: String? = nil,
phExt _: String? = nil)
{
self.a1 = a1
self.a2 = a2
self.c = c
self.st = st
self.cnt = cnt
self.pC = pC
self.ph = ph
}
}
public struct PI: Codable {
public let id: String
public let cTD: CTD
public let nu: String
public let em: String
public let er: String
}
public struct CTD: Codable {
public let code: String
public let name: String
}
public struct LYY: Codable {
public let id: String?
public let tsSS: String
public let tsTC: String
public let tsWC: String
public let tsWG: String
public let tsSD: String
public let tsSDu: String
public let sdSDEd: String
public let sdSV: String
public let tsO: String
public let tsP: String
public let tsSH: String
var nu: String?
public let banner: String?
public let eL: Int?
public let let: String?
public let pi: String?
}
public enum MS: String, Codable {
case pe = "end"
case sb = "it"
case none
}
public struct UP: Decodable {
public var una: String?
public var lan: String?
public var dob: String?
public var fN: String?
public var lN: String?
public var eai: String?
public var gen: String?
public var bac: Double?
public var nP: String?
public var cuI: String?
public var mS: MS = .none // crashes here
public var acS: String?
public var eSc: Bool?
public var tBac: Double?
public var lyy: LYY?
public var hAds: ADS?
public var bAds: ADS?
public var pIs: [PI]?
public let lUd = Date()
public var cry: String?
public var lmP: Int?
public var lyyNu: String? {
get {
lyy?.nu
}
set {
lyy?.nu = newValue
}
}
public func getProfileDictionary() -> [String: Any]? {
return nil // unneeded
}
public var isUserLYY: Bool {
false // unneeded
}
public init() {
}
public init(from decoder: Decoder) throws {
// unneeded
}
}
Stack Trace
Xcode log output