52 lines
1.2 KiB
Swift
52 lines
1.2 KiB
Swift
//
|
|
// Bundle.swift
|
|
// VDSSample
|
|
//
|
|
// Created by Matt Bruce on 12/5/23.
|
|
//
|
|
|
|
import Foundation
|
|
import VDS
|
|
|
|
extension Bundle {
|
|
var versionNumber: String? {
|
|
infoDictionary?["CFBundleShortVersionString"] as? String
|
|
}
|
|
var buildNumber: String? {
|
|
infoDictionary?["CFBundleVersion"] as? String
|
|
}
|
|
|
|
var build: String? {
|
|
guard let versionNumber, let buildNumber else { return nil }
|
|
return "\(versionNumber).\(buildNumber)"
|
|
}
|
|
|
|
func contents(_ fileName: String, fileExtension: String = "txt" ) -> String? {
|
|
guard let fileURL = url(forResource: fileName, withExtension: fileExtension) else { return nil }
|
|
do {
|
|
return try String(contentsOf: fileURL)
|
|
} catch {
|
|
print("error reading releaseNotes")
|
|
return "none"
|
|
}
|
|
}
|
|
}
|
|
|
|
struct VDSHelper {
|
|
static var bundle: Bundle {
|
|
VDS.Bundle(for: VDS.Badge.self)
|
|
}
|
|
|
|
static var version: String {
|
|
bundle.versionNumber ?? ""
|
|
}
|
|
|
|
static func releaseNotes() -> String {
|
|
return bundle.contents("ReleaseNotes") ?? ""
|
|
}
|
|
|
|
static func changeLog(for component: ViewProtocol.Type) -> String? {
|
|
return bundle.contents("\(component.self)ChangeLog")
|
|
}
|
|
}
|