Skip to content

Commit 6c948b0

Browse files
jaeoptthomaszurkan-optimizely
authored andcommitted
improve ios SDK release process (#350)
* remove UserProfile project ref inside Datafile project * fix CocoaPods and Carthage version number to compatible numbers * add instruction to add Carthage output file paths * automate version update for xcode projects and cocaopod specs * pass version as argument
1 parent 4e1f9bd commit 6c948b0

File tree

5 files changed

+159
-76
lines changed

5 files changed

+159
-76
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ fastlane/screenshots
6868
# https://github.com/johnno1962/injectionforxcode
6969

7070
iOSInjectionProject/
71+
72+
# tests
73+
testResults/
74+

OptimizelySDK.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OptimizelySDKDatafileManager/OptimizelySDKDatafileManager.xcodeproj/project.pbxproj

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -111,34 +111,6 @@
111111
remoteGlobalIDString = EA5247221DC7193B00AF6685;
112112
remoteInfo = OptimizelySDKSharedTVOS;
113113
};
114-
EA6112951EC288E5001967ED /* PBXContainerItemProxy */ = {
115-
isa = PBXContainerItemProxy;
116-
containerPortal = EA61128C1EC288E5001967ED /* OptimizelySDKUserProfileService.xcodeproj */;
117-
proxyType = 2;
118-
remoteGlobalIDString = EA5248441DC72B5500AF6685;
119-
remoteInfo = OptimizelySDKUserProfileServiceiOS;
120-
};
121-
EA6112971EC288E5001967ED /* PBXContainerItemProxy */ = {
122-
isa = PBXContainerItemProxy;
123-
containerPortal = EA61128C1EC288E5001967ED /* OptimizelySDKUserProfileService.xcodeproj */;
124-
proxyType = 2;
125-
remoteGlobalIDString = EA52484C1DC72B5500AF6685;
126-
remoteInfo = OptimizelySDKUserProfileServiceiOSTests;
127-
};
128-
EA6112991EC288E5001967ED /* PBXContainerItemProxy */ = {
129-
isa = PBXContainerItemProxy;
130-
containerPortal = EA61128C1EC288E5001967ED /* OptimizelySDKUserProfileService.xcodeproj */;
131-
proxyType = 2;
132-
remoteGlobalIDString = EA5248641DC72B6500AF6685;
133-
remoteInfo = OptimizelySDKUserProfileServiceTVOS;
134-
};
135-
EA61129B1EC288E5001967ED /* PBXContainerItemProxy */ = {
136-
isa = PBXContainerItemProxy;
137-
containerPortal = EA61128C1EC288E5001967ED /* OptimizelySDKUserProfileService.xcodeproj */;
138-
proxyType = 2;
139-
remoteGlobalIDString = EA52486C1DC72B6500AF6685;
140-
remoteInfo = OptimizelySDKUserProfileServiceTVOSTests;
141-
};
142114
/* End PBXContainerItemProxy section */
143115

144116
/* Begin PBXFileReference section */
@@ -178,7 +150,6 @@
178150
EA52488A1DC72C5300AF6685 /* OptimizelySDKShared.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OptimizelySDKShared.xcodeproj; path = ../OptimizelySDKShared/OptimizelySDKShared.xcodeproj; sourceTree = "<group>"; };
179151
EA5249491DC72FF200AF6685 /* OPTLYDatafileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OPTLYDatafileManager.h; sourceTree = "<group>"; };
180152
EA52494A1DC72FF200AF6685 /* OPTLYDatafileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYDatafileManager.m; sourceTree = "<group>"; };
181-
EA61128C1EC288E5001967ED /* OptimizelySDKUserProfileService.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OptimizelySDKUserProfileService.xcodeproj; path = ../OptimizelySDKUserProfileService/OptimizelySDKUserProfileService.xcodeproj; sourceTree = "<group>"; };
182153
EA8FD10B1DED2B9D00D950AD /* OPTLYDatafileManagerBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OPTLYDatafileManagerBuilder.h; sourceTree = "<group>"; };
183154
EA8FD10C1DED2B9D00D950AD /* OPTLYDatafileManagerBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYDatafileManagerBuilder.m; sourceTree = "<group>"; };
184155
F11A4F80C7960C4907845910 /* Pods_OptimizelySDKDatafileManageriOSTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OptimizelySDKDatafileManageriOSTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -253,7 +224,6 @@
253224
EA3C68B11DC1E75800C578CA = {
254225
isa = PBXGroup;
255226
children = (
256-
EA61128C1EC288E5001967ED /* OptimizelySDKUserProfileService.xcodeproj */,
257227
EA3C68BD1DC1E75900C578CA /* OptimizelySDKDatafileManager */,
258228
EA3C68C91DC1E75900C578CA /* OptimizelySDKDatafileManagerTests */,
259229
EA3C68BC1DC1E75900C578CA /* Products */,
@@ -328,17 +298,6 @@
328298
name = Products;
329299
sourceTree = "<group>";
330300
};
331-
EA61128D1EC288E5001967ED /* Products */ = {
332-
isa = PBXGroup;
333-
children = (
334-
EA6112961EC288E5001967ED /* OptimizelySDKUserProfileService.framework */,
335-
EA6112981EC288E5001967ED /* OptimizelySDKUserProfileServiceiOSTests.xctest */,
336-
EA61129A1EC288E5001967ED /* OptimizelySDKUserProfileService.framework */,
337-
EA61129C1EC288E5001967ED /* OptimizelySDKUserProfileServiceTVOSTests.xctest */,
338-
);
339-
name = Products;
340-
sourceTree = "<group>";
341-
};
342301
/* End PBXGroup section */
343302

344303
/* Begin PBXHeadersBuildPhase section */
@@ -487,10 +446,6 @@
487446
ProductGroup = EA52488B1DC72C5300AF6685 /* Products */;
488447
ProjectRef = EA52488A1DC72C5300AF6685 /* OptimizelySDKShared.xcodeproj */;
489448
},
490-
{
491-
ProductGroup = EA61128D1EC288E5001967ED /* Products */;
492-
ProjectRef = EA61128C1EC288E5001967ED /* OptimizelySDKUserProfileService.xcodeproj */;
493-
},
494449
);
495450
projectRoot = "";
496451
targets = (
@@ -538,34 +493,6 @@
538493
remoteRef = EA5248971DC72C5300AF6685 /* PBXContainerItemProxy */;
539494
sourceTree = BUILT_PRODUCTS_DIR;
540495
};
541-
EA6112961EC288E5001967ED /* OptimizelySDKUserProfileService.framework */ = {
542-
isa = PBXReferenceProxy;
543-
fileType = wrapper.framework;
544-
path = OptimizelySDKUserProfileService.framework;
545-
remoteRef = EA6112951EC288E5001967ED /* PBXContainerItemProxy */;
546-
sourceTree = BUILT_PRODUCTS_DIR;
547-
};
548-
EA6112981EC288E5001967ED /* OptimizelySDKUserProfileServiceiOSTests.xctest */ = {
549-
isa = PBXReferenceProxy;
550-
fileType = wrapper.cfbundle;
551-
path = OptimizelySDKUserProfileServiceiOSTests.xctest;
552-
remoteRef = EA6112971EC288E5001967ED /* PBXContainerItemProxy */;
553-
sourceTree = BUILT_PRODUCTS_DIR;
554-
};
555-
EA61129A1EC288E5001967ED /* OptimizelySDKUserProfileService.framework */ = {
556-
isa = PBXReferenceProxy;
557-
fileType = wrapper.framework;
558-
path = OptimizelySDKUserProfileService.framework;
559-
remoteRef = EA6112991EC288E5001967ED /* PBXContainerItemProxy */;
560-
sourceTree = BUILT_PRODUCTS_DIR;
561-
};
562-
EA61129C1EC288E5001967ED /* OptimizelySDKUserProfileServiceTVOSTests.xctest */ = {
563-
isa = PBXReferenceProxy;
564-
fileType = wrapper.cfbundle;
565-
path = OptimizelySDKUserProfileServiceTVOSTests.xctest;
566-
remoteRef = EA61129B1EC288E5001967ED /* PBXContainerItemProxy */;
567-
sourceTree = BUILT_PRODUCTS_DIR;
568-
};
569496
/* End PBXReferenceProxy section */
570497

571498
/* Begin PBXResourcesBuildPhase section */

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Please note below that _\<platform\>_ is used to represent the platform on which
2727
#### Cocoapod
2828
1. Add the following lines to the _Podfile_:<pre>
2929
```use_frameworks!```
30-
```pod 'OptimizelySDK<platform>', '2.1.4'```
30+
```pod 'OptimizelySDK<platform>', '~> 2.1.0'```
3131
</pre>
3232

3333
2. Run the following command: <pre>``` pod install ```</pre>
@@ -36,7 +36,7 @@ Further installation instructions for Cocoapods: https://guides.cocoapods.org/us
3636

3737
#### Carthage
3838
1. Add the following lines to the _Cartfile_:<pre>
39-
github "optimizely/objective-c-sdk" "v2.1.4"
39+
github "optimizely/objective-c-sdk" ~> 2.1.0
4040
</pre>
4141

4242
2. Run the following command:<pre>```carthage update```</pre>
@@ -53,13 +53,20 @@ github "optimizely/objective-c-sdk" "v2.1.4"
5353
- Add a new **Run Script** phase in your target's **Build Phase**.</br>
5454
- In the script area include:<pre>
5555
```/usr/local/bin/carthage copy-frameworks```</pre>
56-
- Add the frameworks to the **Input Files** list:<pre>
56+
- Add the paths to the frameworks to the **Input Files** list:<pre>
5757
```$(SRCROOT)/Carthage/Build/<platform>/OptimizelySDKCore.framework```
5858
```$(SRCROOT)/Carthage/Build/<platform>/OptimizelySDKDatafileManager.framework```
5959
```$(SRCROOT)/Carthage/Build/<platform>/OptimizelySDKEventDispatcher.framework```
6060
```$(SRCROOT)/Carthage/Build/<platform>/OptimizelySDKShared.framework```
6161
```$(SRCROOT)/Carthage/Build/<platform>/OptimizelySDKUserProfileService.framework```
6262
```$(SRCROOT)/Carthage/Build/<platform>/OptimizelySDK<platform>.framework```</pre>
63+
- Add the paths to the copied frameworks to the **Output Files** list:<pre>
64+
```$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/OptimizelySDKCore.framework```
65+
```$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/OptimizelySDKDatafileManager.framework```
66+
```$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/OptimizelySDKEventDispatcher.framework```
67+
```$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/OptimizelySDKShared.framework```
68+
```$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/OptimizelySDKUserProfileService.framework```
69+
```$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/OptimizelySDK<platform>.framework```</pre>
6370

6471
Futher installation instructions for Carthage: https://github.com/Carthage/Carthage
6572

Scripts/update_version.sh

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/bin/bash
2+
3+
# update_version.sh
4+
#
5+
# This script consistently updates the SDK version numbers in several places:
6+
# 1. {XcodeProject}/{XcodeProject}.xcodeproj/project.pbxproj
7+
# 2. {XcodeProject}.podspec
8+
#
9+
# Usage:
10+
# $ ./update_version.sh [releaseSDKVersion]
11+
#
12+
13+
14+
#----------------------------------------------------------------------------------
15+
# set the release SDK version
16+
#----------------------------------------------------------------------------------
17+
if [ "$#" -eq "1" ];
18+
then
19+
releaseSDKVersion="$1"
20+
else
21+
read -p "Enter the new SDK release version (ex: 2.1.4): " releaseSDKVersion;
22+
fi
23+
24+
varComps=( ${releaseSDKVersion//./ } )
25+
26+
if (( ${#varComps[@]} != 3 )); then
27+
printf "\n[ERROR] Invalid target version number: ${releaseSDKVersion} \n"
28+
exit 1
29+
fi
30+
31+
vMajor=${varComps[0]}
32+
vMinor=${varComps[1]}
33+
vPatch=${varComps[2]}
34+
35+
printf "\nRelease SDK Version: ${releaseSDKVersion} \n"
36+
37+
cd "$(dirname $0)/.."
38+
39+
#----------------------------------------------------------------------------------
40+
# 1. update the SDK version in all xcode project settings
41+
#----------------------------------------------------------------------------------
42+
# SDK submodules + universal
43+
mods=(OptimizelySDKCore \
44+
OptimizelySDKShared \
45+
OptimizelySDKDatafileManager \
46+
OptimizelySDKEventDispatcher \
47+
OptimizelySDKUserProfileService \
48+
OptimizelySDKiOS \
49+
OptimizelySDKTVOS \
50+
OptimizelySDKUniversal)
51+
numMods=${#mods[@]}
52+
53+
printf "\n\nReplacing OPTIMIZELY_SDK_VERSION in Xcode Build Settings to the target version.\n"
54+
55+
for (( i = 0; i < ${numMods}; i++ ))
56+
do
57+
curMod=${mods[i]}
58+
curPbxProjPath=${curMod}/${curMod}.xcodeproj/project.pbxproj
59+
printf "\t[${curMod}] Updating .pbxproj to ${releaseSDKVersion}.\n"
60+
61+
sed -i '' -e "s/\(OPTIMIZELY_SDK_VERSION_MAJOR[ ]*\)=.*;/\1= ${vMajor};/g" ${curPbxProjPath}
62+
sed -i '' -e "s/\(OPTIMIZELY_SDK_VERSION_MINOR[ ]*\)=.*;/\1= ${vMinor};/g" ${curPbxProjPath}
63+
sed -i '' -e "s/\(OPTIMIZELY_SDK_VERSION_PATCH[ ]*\)=.*;/\1= ${vPatch};/g" ${curPbxProjPath}
64+
done
65+
66+
printf "Verifying OPTIMIZELY_SDK_VERSION from Xcode Build Settings.\n";
67+
68+
for (( i = 0; i < ${numMods}; i++ ))
69+
do
70+
curMod=${mods[i]}
71+
curProjPath=${curMod}/${curMod}.xcodeproj
72+
73+
OPTIMIZELY_SDK_VERSION=$(Xcodebuild -project ${curProjPath} -showBuildSettings | sed -n 's/OPTIMIZELY_SDK_VERSION = \(.*\)/\1/p' | sed 's/ //g');
74+
75+
if [ "${OPTIMIZELY_SDK_VERSION}" == "${releaseSDKVersion}" ]
76+
then
77+
printf "\t[${curMod}] OPTIMIZELY_SDK_VERSION in xcode settings verified: ${releaseSDKVersion}/${OPTIMIZELY_SDK_VERSION}\n"
78+
else
79+
printf "\n[ERROR][${curMod}] OPTIMIZELY_SDK_VERSION mismatch: (releaseSDKVersion/OPTIMIZELY_SDK_VERSION) = ${releaseSDKVersion}/${OPTIMIZELY_SDK_VERSION}\n";
80+
exit 1
81+
fi
82+
83+
done
84+
85+
86+
#----------------------------------------------------------------------------------
87+
# 2. update the SDK version in all podspecs
88+
#----------------------------------------------------------------------------------
89+
podSpecs=(OptimizelySDKCore.podspec \
90+
OptimizelySDKShared.podspec \
91+
OptimizelySDKDatafileManager.podspec \
92+
OptimizelySDKEventDispatcher.podspec \
93+
OptimizelySDKUserProfileService.podspec \
94+
OptimizelySDKiOS.podspec \
95+
OptimizelySDKTVOS.podspec)
96+
numPodSpecs=${#podSpecs[@]};
97+
98+
printf "\n\nReplacing all versions in *.podspec files\n"
99+
100+
for (( i = 0; i < ${numPodSpecs}; i++ ));
101+
do
102+
curPodSpec=${podSpecs[i]}
103+
104+
printf "\t[${curPodSpec}] Updating podspec to ${releaseSDKVersion}.\n"
105+
sed -i '' -e "s/\(s\.version[ ]*\)=[ ]*\".*\"/\1= \"${releaseSDKVersion}\"/g" ${curPodSpec}
106+
sed -i '' -e "s/\(s\.dependency[ ]*[\'\"]OptimizelySDK.*[\'\"].*\,\)[ ]*[\'\"].*[\'\"]/\1 \"${releaseSDKVersion}\"/g" ${curPodSpec}
107+
done
108+
109+
# pod-spec-lint cannot be run here due to dependency issues
110+
# all podspecs will be validated anyway when uploading to CocoaPods repo
111+
112+
printf "Verifying *.podspec files\n"
113+
114+
countChanges=0
115+
116+
for (( i = 0; i < ${numPodSpecs}; i++ ))
117+
do
118+
curPodSpec=${podSpecs[i]}
119+
120+
vm=$(sed -n "s/s\.version.*=.*\"\(.*\)\"/\1/p" ${curPodSpec} | sed "s/ //g" )
121+
if [ "${vm}" == "${releaseSDKVersion}" ]; then countChanges=$(( countChanges + 1 )); fi
122+
123+
deps=$(sed -n "s/s\.dependency.*OptimizelySDK.*\"\(.*\)\"/\1/p" ${curPodSpec} | sed "s/ //g" )
124+
deps=( ${deps//\n/ } )
125+
for (( j = 0; j < ${#deps[@]}; j++ )); do
126+
if [ "${deps[j]}" == "${releaseSDKVersion}" ]; then countChanges=$(( countChanges + 1 )); fi
127+
done
128+
129+
printf "\t[${curPodSpec}] Verified podspec: ${releaseSDKVersion}\n"
130+
done
131+
132+
# check total 17 (= 7 + 10) places replaced
133+
expTotalCount=17
134+
if (( ${countChanges} == ${expTotalCount} ))
135+
then
136+
printf "Verified successfully! (podspec version updated in ${expTotalCount} places) \n"
137+
else
138+
printf "\n[ERROR] podspec version update failed (count=${countChanges}). check it out! \n"
139+
exit 1
140+
fi
141+
142+
printf "\n\n[SUCCESS] All release-skd-version settings have been updated successfully!\n\n\n"

0 commit comments

Comments
 (0)