Created
June 13, 2021 10:34
-
-
Save Maschina/f69532eab2a71217d749c13070090bdd to your computer and use it in GitHub Desktop.
Get compilation time in Swift. Credits go to Alain. T (https://stackoverflow.com/a/38421481/873072)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Get the build date and time | |
var compileTime: Date { | |
let bundleName = Bundle.main.infoDictionary!["CFBundleName"] as? String ?? "Info.plist" | |
if let infoPath = Bundle.main.path(forResource: bundleName, ofType: nil), | |
let infoAttr = try? FileManager.default.attributesOfItem(atPath: infoPath), | |
let infoDate = infoAttr[FileAttributeKey.creationDate] as? Date | |
{ return infoDate } | |
return Date() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment