I am able to display the build date for my app in the simulator, but whenever I archive the app, and upload it to TestFlight, and then install it on a device, the build date doe
static var buildDate: Date? {
guard let infoPath = Bundle.main.path(forResource: "Info.plist", ofType: nil) else {
return nil
}
guard let infoAttr = try? FileManager.default.attributesOfItem(atPath: infoPath) else {
return nil
}
let key = FileAttributeKey(rawValue: "NSFileCreationDate")
guard let infoDate = infoAttr[key] as? Date else {
return nil
}
return infoDate
}
static var prettyBuildDate: String {
guard let date = buildDate else {
return "Unknown"
}
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ"
formatter.timeZone = TimeZone(abbreviation: "UTC")
return formatter.string(from: date)
}