I would tend to think that the issue is with the try! statement. write(to:) can throw, which is probably the case here. Force unwrapping probably causes the crash.
Here's an example of an implementation that works (at least on my end):
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(contentType: .myArchive) { archive in
let url = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent(archive.fileName)
let res = try JSONEncoder().encode(archive)
try res.write(to: url, options: .atomicWrite)
return SentTransferredFile(url)
} importing: { received in
let data = try Data(contentsOf: received.file)
return try JSONDecoder().decode(MyArchive.self, from: data)
}
}