Add display name to Bundle/BundleInformation

This commit is contained in:
Daniel Saidi 2021-11-03 12:56:54 +01:00
parent 214069fa72
commit 53e77cddf0
3 changed files with 28 additions and 6 deletions

View File

@ -9,6 +9,10 @@ There are no drastic changes, but I use this in most of my projects and find it
This version drastically improves documentation and ships with a DocC documentation archive.
### ✨ New features
* `String` has new `boolValue` extension.
* `Bundle` has a new `displayName` extension.
## 0.7.0

View File

@ -9,12 +9,12 @@
import Foundation
/**
These extensions make `Bundle` imlement `BundleInformation`.
This extensions make `Bundle` implement ``BundleInformation``.
*/
extension Bundle: BundleInformation {
/**
Get the bundle build number.
Get the bundle build number, e.g. `42567`.
*/
public var buildNumber: String {
let key = String(kCFBundleVersionKey)
@ -23,7 +23,14 @@ extension Bundle: BundleInformation {
}
/**
Get the bundle version number.
Get the bundle display name, if any.
*/
public var displayName: String {
infoDictionary?["CFBundleDisplayName"] as? String ?? "-"
}
/**
Get the bundle build number, e.g. `42567`.
*/
public var versionNumber: String {
let key = "CFBundleShortVersionString"

View File

@ -9,11 +9,22 @@
import Foundation
/**
This protocol can be implemented by any struct and/or class
that can provide information about the current bundle.
This protocol can be implemented by types that can provide information about the current bundle.
*/
public protocol BundleInformation {
/**
Get the bundle build number, e.g. `42567`.
*/
var buildNumber: String { get }
/**
Get the bundle display name, if any.
*/
var displayName: String { get }
/**
Get the bundle build number, e.g. `42567`.
*/
var versionNumber: String { get }
}