Swift 5 Read binary file ( problem with unsafe mutable pointers)

Since Data can be read as a sequence of UInt8 you can use one of the techniques described here:

A simplified example of what is described there that only reads Int16 would be something like this (note that this example assumes the data is stored as big endian and that it will discard the last byte if the number of bytes in Data is odd):

var numbers: [Int16] = []
for index in data.startIndex ..< data.index(before: data.endIndex) {
let num = Int16(data[index]) << 8 + Int16(data[data.index(after: index)])
    numbers.append(num)
}