File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -70,12 +70,15 @@ class ApplicationInfo: ApplicationInfoProtocol {
70
70
71
71
private let networkInformation : NetworkInfoProtocol
72
72
private let envParams : [ String : String ]
73
+ private let infoDict : [ String : Any ] ?
73
74
74
75
init ( appID: String , networkInfo: NetworkInfoProtocol = NetworkInfo ( ) ,
75
- envParams: [ String : String ] = ProcessInfo . processInfo. environment) {
76
+ envParams: [ String : String ] = ProcessInfo . processInfo. environment,
77
+ infoDict: [ String : Any ] ? = Bundle . main. infoDictionary) {
76
78
self . appID = appID
77
79
networkInformation = networkInfo
78
80
self . envParams = envParams
81
+ self . infoDict = infoDict
79
82
}
80
83
81
84
var sdkVersion : String {
@@ -107,11 +110,11 @@ class ApplicationInfo: ApplicationInfoProtocol {
107
110
}
108
111
109
112
var appBuildVersion : String {
110
- return Bundle . main . infoDictionary ? [ " CFBundleShortVersionString " ] as? String ?? " "
113
+ return infoDict ? [ " CFBundleVersion " ] as? String ?? " "
111
114
}
112
115
113
116
var appDisplayVersion : String {
114
- return Bundle . main . infoDictionary ? [ " CFBundleVersion " ] as? String ?? " "
117
+ return infoDict ? [ " CFBundleShortVersionString " ] as? String ?? " "
115
118
}
116
119
117
120
var osBuildVersion : String {
Original file line number Diff line number Diff line change @@ -104,4 +104,18 @@ class ApplicationInfoTests: XCTestCase {
104
104
appInfo = ApplicationInfo ( appID: " testAppID " , envParams: envValues)
105
105
XCTAssertEqual ( appInfo. environment, . prod)
106
106
}
107
+
108
+ func test_bundleVersions_correspondToVersion( ) {
109
+ let appInfo = ApplicationInfo (
110
+ appID: " testAppID " ,
111
+ networkInfo: mockNetworkInfo,
112
+ envParams: [ : ] ,
113
+ infoDict: [
114
+ " CFBundleVersion " : " 54321 " , // Build Version
115
+ " CFBundleShortVersionString " : " 12.34.5 " , // Display Version
116
+ ]
117
+ )
118
+ XCTAssertEqual ( appInfo. appBuildVersion, " 54321 " )
119
+ XCTAssertEqual ( appInfo. appDisplayVersion, " 12.34.5 " )
120
+ }
107
121
}
You can’t perform that action at this time.
0 commit comments