I have a ProfileRegistration struct which is just a basic model. I haven't had any problems with it. However as soon as I add a new property to the model the app crashes at runtime as soon as it is accessed anywhere in code.
// Causes app to crash
struct ProfileRegistration: Codable {
let resourceNumber: String?
let nickName: String?
let firstName: String?
let initials: String?
let name: String?
let lastName: String?
let gender: Gender?
let birthdate: String?
let nationality: String?
let phoneNumber: String?
let email: String?
let insuranceNumber: String?
let employmentDate: String?
let username: String?
var worksteadLocations: [WorksteadLocation] = []
var coworkerInformations: [CoworkerInformation] = []
var worksteadLocation: WorksteadLocation? {
worksteadLocations.first
}
var jobCoachFirstName: String? {
coworkerInformations.first?.firstName
}
}
// Doesn't cause app to crash
struct ProfileRegistration: Codable {
let resourceNumber: String?
let nickName: String?
let firstName: String?
let initials: String?
// let name: String?
let lastName: String?
let gender: Gender?
let birthdate: String?
let nationality: String?
let phoneNumber: String?
let email: String?
let insuranceNumber: String?
let employmentDate: String?
let username: String?
var worksteadLocations: [WorksteadLocation] = []
var coworkerInformations: [CoworkerInformation] = []
var worksteadLocation: WorksteadLocation? {
worksteadLocations.first
}
var jobCoachFirstName: String? {
coworkerInformations.first?.firstName
}
}
I get the error:
Thread 10: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
Right above the error in the stack I see this
async function pointer to reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> (@owned Workstead.ProfileRegistration, @error @owned Swift.Error) to @escaping @callee_guaranteed @async () -> (@out Workstead.ProfileRegistration, @error @owned Swift.Error)
Complete stack:
Workstead`partial apply for thunk for @escaping @callee_guaranteed @Sendable @async () -> (@owned ProfileRegistration, @error @owned Error):
0x102cc10f0 < 0>: orq 0x9d5409(%rip), %rbp ; (void *)0x1000000000000000
0x102cc10f7 < 7>: pushq %rbp
0x102cc10f8 < 8>: pushq %r14
0x102cc10fa < 10>: leaq 0x8(%rsp), %rbp
0x102cc10ff < 15>: subq $0x38, %rsp
0x102cc1103 < 19>: movq %r14, -0x10(%rbp)
0x102cc1107 < 23>: movq %rdi, -0x28(%rbp)
0x102cc110b < 27>: xorl