-
Notifications
You must be signed in to change notification settings - Fork 749
Expand file tree
/
Copy pathBundle+Helpers.swift
More file actions
30 lines (24 loc) · 1000 Bytes
/
Bundle+Helpers.swift
File metadata and controls
30 lines (24 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Foundation
import ApolloCore
extension Bundle: ApolloCompatible {}
extension ApolloExtension where Base == Bundle {
/// Type-safe getter for info dictionary key objects
///
/// - Parameter key: The key to try to grab an object for
/// - Returns: The object of the desired type, or nil if it is not present or of the incorrect type.
func bundleValue<T>(forKey key: String) -> T? {
return base.object(forInfoDictionaryKey: key) as? T
}
/// The bundle identifier of this bundle, or nil if not present.
var bundleIdentifier: String? {
return self.bundleValue(forKey: String(kCFBundleIdentifierKey))
}
/// The build number of this bundle (kCFBundleVersion) as a string, or nil if not present.
var buildNumber: String? {
return self.bundleValue(forKey: String(kCFBundleVersionKey))
}
/// The short version string for this bundle, or nil if not present.
var shortVersion: String? {
return self.bundleValue(forKey: "CFBundleShortVersionString")
}
}