Skip to content

Commit 5f5b319

Browse files
(chore):another way to set version (#179)
* another way to set version * add some comments
1 parent fab0386 commit 5f5b319

File tree

4 files changed

+68
-11
lines changed

4 files changed

+68
-11
lines changed

OptimizelySDK/OptimizelySwiftSDK.xcodeproj/project.pbxproj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@
114114
0BC47BE62243012E00E5C2CD /* MurmurTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC47BE42243012E00E5C2CD /* MurmurTests.swift */; };
115115
0BC48EA32203764E003AFD71 /* DataStoreQueueStackImpl+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC48EA22203764E003AFD71 /* DataStoreQueueStackImpl+Extension.swift */; };
116116
0BC48EA522038491003AFD71 /* ArrayEventForDispatch+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC48EA422038491003AFD71 /* ArrayEventForDispatch+Extension.swift */; };
117+
0BDF9DC1228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
118+
0BDF9DC2228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
119+
0BDF9DC3228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
120+
0BDF9DC4228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
121+
0BDF9DC5228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
122+
0BDF9DC6228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
123+
0BDF9DC7228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
124+
0BDF9DC8228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
125+
0BDF9DC9228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
126+
0BDF9DCA228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
127+
0BDF9DCB228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
128+
0BDF9DCC228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */; };
117129
0BE644ED223821D3009A5D1D /* AtomicProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BE644EC223821D3009A5D1D /* AtomicProperty.swift */; };
118130
0BE644EE223821D3009A5D1D /* AtomicProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BE644EC223821D3009A5D1D /* AtomicProperty.swift */; };
119131
0BE644EF223821D3009A5D1D /* AtomicProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BE644EC223821D3009A5D1D /* AtomicProperty.swift */; };
@@ -1208,6 +1220,7 @@
12081220
0BC47BE42243012E00E5C2CD /* MurmurTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MurmurTests.swift; sourceTree = "<group>"; };
12091221
0BC48EA22203764E003AFD71 /* DataStoreQueueStackImpl+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataStoreQueueStackImpl+Extension.swift"; sourceTree = "<group>"; };
12101222
0BC48EA422038491003AFD71 /* ArrayEventForDispatch+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ArrayEventForDispatch+Extension.swift"; sourceTree = "<group>"; };
1223+
0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptimizelySDKVersion.swift; sourceTree = "<group>"; };
12111224
0BE644EC223821D3009A5D1D /* AtomicProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomicProperty.swift; sourceTree = "<group>"; };
12121225
1BB705EF16F51D6560E2516E /* Pods-OptimizelyTests-Common-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OptimizelyTests-Common-tvOS.debug.xcconfig"; path = "Target Support Files/Pods-OptimizelyTests-Common-tvOS/Pods-OptimizelyTests-Common-tvOS.debug.xcconfig"; sourceTree = "<group>"; };
12131226
267A95DA08018A1800FDB35B /* Pods_OptimizelyTests_Common_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OptimizelyTests_Common_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1436,6 +1449,7 @@
14361449
0B0590172209DC180007F4A2 /* HandlerRegistryService.swift */,
14371450
0BE644EC223821D3009A5D1D /* AtomicProperty.swift */,
14381451
6EA0721A223AC72D00F447CF /* Utils.swift */,
1452+
0BDF9DC0228242E500CCD8D1 /* OptimizelySDKVersion.swift */,
14391453
);
14401454
path = Utils;
14411455
sourceTree = "<group>";
@@ -2616,6 +2630,7 @@
26162630
6E4DD85921E5250200B0C2C7 /* OPTBucketer.swift in Sources */,
26172631
6E4DD86521E5250B00B0C2C7 /* EventForDispatch.swift in Sources */,
26182632
0B7B18862231D8B800A1F85D /* DataStoreMemory.swift in Sources */,
2633+
0BDF9DC2228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
26192634
6E4DD84A21E524FC00B0C2C7 /* MurmurHash3.swift in Sources */,
26202635
);
26212636
runOnlyForDeploymentPostprocessing = 0;
@@ -2680,6 +2695,7 @@
26802695
6E4DD8D821E5274600B0C2C7 /* ConditionHolder.swift in Sources */,
26812696
6E4DD88821E525F600B0C2C7 /* BatchEventBuilder.swift in Sources */,
26822697
0BE644F3223821D3009A5D1D /* AtomicProperty.swift in Sources */,
2698+
0BDF9DC9228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
26832699
6E4DD89521E525FD00B0C2C7 /* DefaultUserProfileService.swift in Sources */,
26842700
6E6D66862238132300E04486 /* tvOSOnlyTests.swift in Sources */,
26852701
);
@@ -2734,6 +2750,7 @@
27342750
6E636BE12236C9B700AF3CEF /* ConditionHolder.swift in Sources */,
27352751
6E636BC52236C99D00AF3CEF /* DefaultNotificationCenter.swift in Sources */,
27362752
6E636BBB2236C99300AF3CEF /* DataStoreQueueStackImpl.swift in Sources */,
2753+
0BDF9DC5228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
27372754
6E636BE32236C9B700AF3CEF /* UserAttribute.swift in Sources */,
27382755
6E636BB52236C98A00AF3CEF /* OPTEventDispatcher.swift in Sources */,
27392756
6E636BA62236C97E00AF3CEF /* OptimizelyClient.swift in Sources */,
@@ -2819,6 +2836,7 @@
28192836
6E636C102236C9CB00AF3CEF /* MurmurHash3.swift in Sources */,
28202837
6E636BB12236C98400AF3CEF /* DefaultLogger.swift in Sources */,
28212838
6E636BD52236C9A900AF3CEF /* OPTDecisionService.swift in Sources */,
2839+
0BDF9DC8228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
28222840
6E636BF92236C9BD00AF3CEF /* Rollout.swift in Sources */,
28232841
6E636C132236C9CB00AF3CEF /* HandlerRegistryService.swift in Sources */,
28242842
);
@@ -2871,6 +2889,7 @@
28712889
6EA425372218E4A300B074B5 /* OPTDatafileHandler.swift in Sources */,
28722890
6EA425512218E4A300B074B5 /* ArrayEventForDispatch+Extension.swift in Sources */,
28732891
0BC47BE62243012E00E5C2CD /* MurmurTests.swift in Sources */,
2892+
0BDF9DCA228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
28742893
0BC47BD72242F7EF00E5C2CD /* DatafileHandlerTests.swift in Sources */,
28752894
6E24C4B42257F5E600DF3D71 /* BatchEventBuilderTests_Attributes.swift in Sources */,
28762895
6EA4252D2218E4A300B074B5 /* DataStoreQueueStackImpl.swift in Sources */,
@@ -2952,6 +2971,7 @@
29522971
6EA425A12218E6AE00B074B5 /* AttributeValueTests.swift in Sources */,
29532972
6EA4259E2218E6AE00B074B5 /* ConditionHolderTests_Evaluate.swift in Sources */,
29542973
6EA4261E2218E74F00B074B5 /* OPTUserProfileService.swift in Sources */,
2974+
0BDF9DCB228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
29552975
6EA4261F2218E74F00B074B5 /* DataStoreUserDefaults.swift in Sources */,
29562976
6EA4262E2218E74F00B074B5 /* OPTDataStore.swift in Sources */,
29572977
6EA425A02218E6AE00B074B5 /* RolloutTests.swift in Sources */,
@@ -3051,6 +3071,7 @@
30513071
6EA425DB2218E74D00B074B5 /* DataStoreQueueStackImpl+Extension.swift in Sources */,
30523072
6EA425D82218E74D00B074B5 /* Rollout.swift in Sources */,
30533073
6E8CB5A0224BF4BE00B8CB7A /* DecisionServiceTests_Others.swift in Sources */,
3074+
0BDF9DC4228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
30543075
6EA425B02218E74D00B074B5 /* OptimizelyLogLevel.swift in Sources */,
30553076
6EA425DD2218E74D00B074B5 /* MurmurHash3.swift in Sources */,
30563077
6EA425CF2218E74D00B074B5 /* Project.swift in Sources */,
@@ -3125,6 +3146,7 @@
31253146
6EA425922218E6AD00B074B5 /* AttributeValueTests.swift in Sources */,
31263147
6EA4258F2218E6AD00B074B5 /* ConditionHolderTests_Evaluate.swift in Sources */,
31273148
6EA425EA2218E74E00B074B5 /* OPTUserProfileService.swift in Sources */,
3149+
0BDF9DC6228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
31283150
6EA425EB2218E74E00B074B5 /* DataStoreUserDefaults.swift in Sources */,
31293151
6EA425FA2218E74E00B074B5 /* OPTDataStore.swift in Sources */,
31303152
6EA425912218E6AD00B074B5 /* RolloutTests.swift in Sources */,
@@ -3187,6 +3209,7 @@
31873209
6EA426AE221925BB00B074B5 /* OPTDatafileHandler.swift in Sources */,
31883210
6EA426E02219266600B074B5 /* ThrowableConditionListTest.swift in Sources */,
31893211
6EA4268A221925B100B074B5 /* UserAttribute.swift in Sources */,
3212+
0BDF9DC7228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
31903213
6EA426D2221925DE00B074B5 /* OPTLogger.swift in Sources */,
31913214
6EA426BE221925CD00B074B5 /* BatchEventBuilder.swift in Sources */,
31923215
6EA42690221925B100B074B5 /* FeatureVariable.swift in Sources */,
@@ -3254,6 +3277,7 @@
32543277
6EA426B6221925BC00B074B5 /* OPTDatafileHandler.swift in Sources */,
32553278
6EA426E12219266600B074B5 /* ThrowableConditionListTest.swift in Sources */,
32563279
6EA4269D221925B300B074B5 /* UserAttribute.swift in Sources */,
3280+
0BDF9DCC228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
32573281
6EA426DC221925DF00B074B5 /* OPTLogger.swift in Sources */,
32583282
6EA426C6221925CE00B074B5 /* BatchEventBuilder.swift in Sources */,
32593283
6EA426A3221925B300B074B5 /* FeatureVariable.swift in Sources */,
@@ -3312,6 +3336,7 @@
33123336
6E4DD87321E5251700B0C2C7 /* FeatureFlag.swift in Sources */,
33133337
6E4DD85121E5250200B0C2C7 /* OPTEventDispatcher.swift in Sources */,
33143338
0B7B18852231D8B800A1F85D /* DataStoreMemory.swift in Sources */,
3339+
0BDF9DC1228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
33153340
6EA4264F22191EEC00B074B5 /* Array+Extension.swift in Sources */,
33163341
6E4F0D972213A4EF00DD13A5 /* Project.swift in Sources */,
33173342
6E4DD87621E5251700B0C2C7 /* Group.swift in Sources */,
@@ -3427,6 +3452,7 @@
34273452
6E4DD89021E525FC00B0C2C7 /* DefaultDatafileHandler.swift in Sources */,
34283453
0B05901A2209DC180007F4A2 /* HandlerRegistryService.swift in Sources */,
34293454
0B7B9EA721F2823500056589 /* OPTDataStore.swift in Sources */,
3455+
0BDF9DC3228242E500CCD8D1 /* OptimizelySDKVersion.swift in Sources */,
34303456
0BE644EF223821D3009A5D1D /* AtomicProperty.swift in Sources */,
34313457
6E4DD89D21E5260100B0C2C7 /* Constants.swift in Sources */,
34323458
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
/****************************************************************************
3+
* Copyright 2019, Optimizely, Inc. and contributors *
4+
* *
5+
* Licensed under the Apache License, Version 2.0 (the "License"); *
6+
* you may not use this file except in compliance with the License. *
7+
* You may obtain a copy of the License at *
8+
* *
9+
* http://www.apache.org/licenses/LICENSE-2.0 *
10+
* *
11+
* Unless required by applicable law or agreed to in writing, software *
12+
* distributed under the License is distributed on an "AS IS" BASIS, *
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14+
* See the License for the specific language governing permissions and *
15+
* limitations under the License. *
16+
***************************************************************************/
17+
18+
/// Do not edit this field. It is auto updated to reflect the current version using the runtimeVersion script.
19+
let OPTIMIZELY_SDK_VERSION = "1.0.0"

OptimizelySDK/Utils/Utils.swift

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,8 @@ import Foundation
1818

1919
class Utils {
2020

21-
// - Bundle(for: OptimizelyClient.self) not working properly to get SDK bundle within unit tests
22-
// - Bundle(identifier: bundleIdentifier) works ok consistently
23-
// - CocoaPods uses its own bundle identifier, so let it use Bundle(for:) as a fallback
24-
// CocoaPods copies "s.version" in podspec to "CFBundleShortVersionString" in its own Info.plist file
25-
static var sdkVersion: String = {
26-
let bundle = Bundle(identifier: "com.optimizely.OptimizelySwiftSDK") ?? Bundle(for: OptimizelyClient.self)
27-
guard let version = bundle.infoDictionary?["CFBundleShortVersionString"] as? String else {
28-
return "1.0.0"
29-
}
30-
return version
31-
}()
21+
// from auto-generated variable OPTIMIZEY_SDK_VERSION
22+
static var sdkVersion: String = OPTIMIZELY_SDK_VERSION
3223

3324
// @objc NSNumber can be casted either Bool, Int, or Double
3425
// more filtering required to avoid NSNumber(false, true) interpreted as Int(0, 1) instead of Bool

Scripts/runtimeVersion.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
TEST_VAR=":blush:"
3+
oldName="$1"
4+
newName="$2"
5+
swift_code() {
6+
cat<<EOF
7+
import Foundation
8+
9+
let fs = FileManager.default
10+
11+
let data = fs.contents(atPath: "../OptimizelySDK/Utils/OptimizelySDKVersion.swift")
12+
13+
let str = String(data: data!, encoding: .utf8)
14+
15+
let newStr = str!.replacingOccurrences(of: "$oldName", with: "$newName")
16+
17+
try newStr.write(to: URL(fileURLWithPath: "../OptimizelySDK/Utils/OptimizelySDKVersion.swift"), atomically: true, encoding: .utf8)
18+
19+
EOF
20+
}
21+
echo "$(swift_code)" | swift -

0 commit comments

Comments
 (0)