Skip to content

Commit eed4a88

Browse files
authored
Merge pull request #168 from optimizely/jae/scripts
fix all scripts to support Swift SDK build/test/versions
2 parents c31df22 + fc36c48 commit eed4a88

File tree

7 files changed

+67
-179
lines changed

7 files changed

+67
-179
lines changed

DemoObjCApp/AppDelegate.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,10 @@ @interface AppDelegate ()
3939
@implementation AppDelegate
4040

4141
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
42-
// most of the third-party integrations only support iOS, so the sample code is only targeted for iOS builds
43-
#if TARGET_OS_IOS
44-
45-
#endif
46-
47-
self.userId = [NSString stringWithFormat:@"%d", arc4random()];
48-
self.attributes = @{ @"browser_type": @"safari", @"bool_attr": @(false) };
4942

43+
self.userId = [NSString stringWithFormat:@"%d", arc4random_uniform(300000)];
44+
self.attributes = @{ @"browser_type": @"safari" };
45+
5046
// initialize SDK in one of these two ways:
5147
// (1) asynchronous SDK initialization (RECOMMENDED)
5248
// - fetch a JSON datafile from the server
@@ -133,8 +129,13 @@ -(void)initializeOptimizelySDKWithCustomization {
133129
NSDictionary<NSString *,id> *attributes, NSDictionary<NSString *,id> *eventTags, NSDictionary<NSString *,id> *event) {
134130
NSLog(@"Received track notification: %@ %@ %@ %@ %@", eventKey, userId, attributes, eventTags, event);
135131

132+
136133
#if TARGET_OS_IOS
134+
// most of the third-party integrations only support iOS, so the sample code is only targeted for iOS builds
135+
137136
// Amplitude example
137+
[Amplitude.instance initializeApiKey:@"YOUR_API_KEY_HERE"];
138+
138139
NSString *propertyKey = [NSString stringWithFormat:@"[Optimizely] %@", eventKey];
139140
AMPIdentify *identify = [[AMPIdentify alloc] init];
140141
[identify set:propertyKey value:userId];

DemoSwiftApp/AppDelegate.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4242
}
4343

4444
func applicationDidFinishLaunching(_ application: UIApplication) {
45-
// most of the third-party integrations only support iOS, so the sample code is only targeted for iOS builds
46-
#if os(iOS)
47-
Amplitude.instance().initializeApiKey("YOUR_API_KEY_HERE")
48-
#endif
4945

5046
// initialize SDK in one of these two ways:
5147
// (1) asynchronous SDK initialization (RECOMMENDED)
@@ -118,9 +114,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
118114
_ = optimizely.notificationCenter.addTrackNotificationListener(trackListener: { (eventKey, userId, attributes, eventTags, event) in
119115
print("Received track notification: \(eventKey) \(userId) \(String(describing: attributes)) \(String(describing: eventTags)) \(event)")
120116

117+
// most of the third-party integrations only support iOS, so the sample code is only targeted for iOS builds
121118
#if os(iOS)
122-
119+
123120
// Amplitude example
121+
Amplitude.instance().initializeApiKey("YOUR_API_KEY_HERE")
122+
124123
let propertyKey = "[Optimizely] " + eventKey
125124
let identify = AMPIdentify()
126125
identify.set(propertyKey, value: userId as NSObject?)

OptimizelySDK/OptimizelySwiftSDK.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,9 +3597,9 @@
35973597
MTL_FAST_MATH = YES;
35983598
ONLY_ACTIVE_ARCH = YES;
35993599
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
3600-
OPTIMIZELY_SDK_VERSION_MAJOR = 3;
3601-
OPTIMIZELY_SDK_VERSION_MINOR = 0;
3602-
OPTIMIZELY_SDK_VERSION_PATCH = 0;
3600+
OPTIMIZELY_SDK_VERSION_MAJOR = "3";
3601+
OPTIMIZELY_SDK_VERSION_MINOR = "1";
3602+
OPTIMIZELY_SDK_VERSION_PATCH = "0";
36033603
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta";
36043604
SDKROOT = iphoneos;
36053605
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
@@ -3660,9 +3660,9 @@
36603660
MTL_ENABLE_DEBUG_INFO = NO;
36613661
MTL_FAST_MATH = YES;
36623662
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
3663-
OPTIMIZELY_SDK_VERSION_MAJOR = 3;
3664-
OPTIMIZELY_SDK_VERSION_MINOR = 0;
3665-
OPTIMIZELY_SDK_VERSION_PATCH = 0;
3663+
OPTIMIZELY_SDK_VERSION_MAJOR = "3";
3664+
OPTIMIZELY_SDK_VERSION_MINOR = "1";
3665+
OPTIMIZELY_SDK_VERSION_PATCH = "0";
36663666
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta";
36673667
SDKROOT = iphoneos;
36683668
SWIFT_COMPILATION_MODE = wholemodule;

OptimizelySwiftSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "OptimizelySwiftSDK"
33
s.module_name = "Optimizely"
4-
s.version = "3.0.0"
4+
s.version = "3.1.0-beta"
55
s.summary = "Optimizely server-side testing core framework."
66
s.homepage = "http://developers.optimizely.com/server/reference/index.html?language=objectivec"
77
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }

Scripts/build_all.sh

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/bin/bash
22
################################################################
33
# buildall.sh
4-
# * Not really in production, but a personal script written quickly
5-
# to automate building all the objective-c-sdk workspace schemes .
6-
# * There aren't any tempfiles . Copied and pasted some stuff
7-
# from our unexported_symbols.sh script.
84
################################################################
95
set -e
106

@@ -33,40 +29,9 @@ main() {
3329
# TODO: This isn't the best, but you can supply "clean" to our command.
3430
action="$1"
3531
fi;
36-
# TODO: We'll need to specify certificate for the app builds.
37-
#xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelyiOSDemoApp -configuration Release "${action}"
38-
#xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelyTVOSDemoApp -configuration Release "${action}"
39-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKCoreiOS -configuration Release "${action}"
40-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKCoreTVOS -configuration Release "${action}"
41-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKDatafileManageriOS -configuration Release "${action}"
42-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKDatafileManagerTVOS -configuration Release "${action}"
43-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKEventDispatcheriOS -configuration Release "${action}"
44-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKEventDispatcherTVOS -configuration Release "${action}"
45-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOS -configuration Release "${action}"
46-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOS-Universal -configuration Release "${action}"
47-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOSUniversal -configuration Release "${action}"
48-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKSharediOS -configuration Release "${action}"
49-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKSharedTVOS -configuration Release "${action}"
50-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOS -configuration Release "${action}"
51-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOS-Universal -configuration Release "${action}"
52-
# Xcode IDE is happy with OptimizelySDKTVOSUniversal , we don't know what's up with our *.sh .
53-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOSUniversal -configuration Release "${action}"
54-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKUserProfileServiceiOS -configuration Release "${action}"
55-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKUserProfileServiceTVOS -configuration Release "${action}"
56-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelyiOSDemoApp -configuration Release "${action}"
57-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKCoreiOSTests -configuration Release "${action}"
58-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKCoreTVOSTests -configuration Release "${action}"
59-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKDatafileManageriOSTests -configuration Release "${action}"
60-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKDatafileManagerTVOSTests -configuration Release "${action}"
61-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKEventDispatcheriOSTests -configuration Release "${action}"
62-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKEventDispatcherTVOSTests -configuration Release "${action}"
63-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKiOSTests -configuration Release "${action}"
64-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKSharediOSTests -configuration Release "${action}"
65-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKSharedTVOSTests -configuration Release "${action}"
66-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKTVOSTests -configuration Release "${action}"
67-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKUserProfileServiceiOSTests -configuration Release "${action}"
68-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKUserProfileServiceTVOSTests -configuration Release "${action}"
69-
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelyTVOSDemoApp -configuration Release "${action}"
32+
33+
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -configuration Release "${action}"
34+
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -configuration Release "${action}"
7035
}
7136

7237
main

Scripts/test_all.sh

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,17 @@
1-
#xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelyiOSDemoApp -configuration Release "${action}"
2-
#xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelyTVOSDemoApp -configuration Release "${action}"
3-
echo 'Testing OptimizelySDKUserProfileServiceiOS'
4-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKUserProfileServiceiOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
5-
test
6-
echo 'Testing OptimizelySDKUserProfileServiceTVOS'
7-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKUserProfileServiceTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
8-
test
9-
echo 'Testing OptimizelySDKSharediOS'
10-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKSharediOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
11-
test
12-
echo 'Testing OptimizelySDKSharedTVOS'
13-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKSharedTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
14-
test
15-
echo 'Testing OptimizelySDKCoreiOS'
16-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKCoreiOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
17-
test
18-
echo 'Testing OptimizelySDKCoretvOS'
19-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKCoreTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
20-
test
21-
echo 'Testing OptimizelySDKDatafileManageriOS'
22-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKDatafileManageriOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
23-
test
24-
echo 'Testing OptimizelySDKDatafileManagerTVOS'
25-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKDatafileManagerTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
26-
test
27-
echo 'Testing OptimizelySDKEventDispatcheriOS'
28-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKEventDispatcheriOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
29-
test
30-
echo 'Testing OptimizelySDKEventDispatcherTVOS'
31-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKEventDispatcherTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
32-
test
33-
echo 'Testing OptimizelySDKiOS'
34-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
35-
test
36-
echo 'Testing OptimizelySDKiOSUniversal'
37-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOSUniversal -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
38-
test
39-
echo 'Testing OptimizelySDKTVOS'
40-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
41-
test
42-
# Xcode IDE is happy with OptimizelySDKTVOSUniversal , we don't know what's up with our *.sh .
43-
echo 'Testing OptimizelySDKTVOSUniversal'
44-
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOSUniversal -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
45-
test
1+
echo 'Testing OptimizelySwiftSDK-iOS (iPhone 6,OS=9.2)'
2+
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0' test
3+
echo 'Testing OptimizelySwiftSDK-iOS (iPhone 8,OS=12.1)'
4+
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8,OS=12.1' test
5+
echo 'Testing OptimizelySwiftSDK-iOS (iPhone SE,OS=10.0)'
6+
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone SE,OS=10.0' test
7+
echo 'Testing OptimizelySwiftSDK-iOS (iPhone XS,OS=12.1)'
8+
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone XS,OS=12.1' test
9+
10+
echo 'Testing OptimizelySwiftSDK-tvOS (Apple TV 1080p,OS=9.0)'
11+
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV 1080p,OS=9.0' test
12+
echo 'Testing OptimizelySwiftSDK-tvOS (Apple TV,OS=11.0)'
13+
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=11.0' test
14+
echo 'Testing OptimizelySwiftSDK-tvOS (Apple TV,OS=12.1)'
15+
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.1' test
16+
echo 'Testing OptimizelySwiftSDK-tvOS (Apple TV 4K,OS=12.1)'
17+
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV 4K,OS=12.1' test

0 commit comments

Comments
 (0)