Skip to content

fix all scripts to support Swift SDK build/test/versions #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions DemoObjCApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ @interface AppDelegate ()
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// most of the third-party integrations only support iOS, so the sample code is only targeted for iOS builds
#if TARGET_OS_IOS

#endif

self.userId = [NSString stringWithFormat:@"%d", arc4random()];
self.attributes = @{ @"browser_type": @"safari", @"bool_attr": @(false) };

self.userId = [NSString stringWithFormat:@"%d", arc4random_uniform(300000)];
self.attributes = @{ @"browser_type": @"safari" };

// initialize SDK in one of these two ways:
// (1) asynchronous SDK initialization (RECOMMENDED)
// - fetch a JSON datafile from the server
Expand Down Expand Up @@ -133,8 +129,13 @@ -(void)initializeOptimizelySDKWithCustomization {
NSDictionary<NSString *,id> *attributes, NSDictionary<NSString *,id> *eventTags, NSDictionary<NSString *,id> *event) {
NSLog(@"Received track notification: %@ %@ %@ %@ %@", eventKey, userId, attributes, eventTags, event);


#if TARGET_OS_IOS
// most of the third-party integrations only support iOS, so the sample code is only targeted for iOS builds

// Amplitude example
[Amplitude.instance initializeApiKey:@"YOUR_API_KEY_HERE"];

NSString *propertyKey = [NSString stringWithFormat:@"[Optimizely] %@", eventKey];
AMPIdentify *identify = [[AMPIdentify alloc] init];
[identify set:propertyKey value:userId];
Expand Down
9 changes: 4 additions & 5 deletions DemoSwiftApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

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

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

// most of the third-party integrations only support iOS, so the sample code is only targeted for iOS builds
#if os(iOS)

// Amplitude example
Amplitude.instance().initializeApiKey("YOUR_API_KEY_HERE")

let propertyKey = "[Optimizely] " + eventKey
let identify = AMPIdentify()
identify.set(propertyKey, value: userId as NSObject?)
Expand Down
12 changes: 6 additions & 6 deletions OptimizelySDK/OptimizelySwiftSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3597,9 +3597,9 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
OPTIMIZELY_SDK_VERSION_MAJOR = 3;
OPTIMIZELY_SDK_VERSION_MINOR = 0;
OPTIMIZELY_SDK_VERSION_PATCH = 0;
OPTIMIZELY_SDK_VERSION_MAJOR = "3";
OPTIMIZELY_SDK_VERSION_MINOR = "1";
OPTIMIZELY_SDK_VERSION_PATCH = "0";
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
Expand Down Expand Up @@ -3660,9 +3660,9 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
OPTIMIZELY_SDK_VERSION_MAJOR = 3;
OPTIMIZELY_SDK_VERSION_MINOR = 0;
OPTIMIZELY_SDK_VERSION_PATCH = 0;
OPTIMIZELY_SDK_VERSION_MAJOR = "3";
OPTIMIZELY_SDK_VERSION_MINOR = "1";
OPTIMIZELY_SDK_VERSION_PATCH = "0";
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta";
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
2 changes: 1 addition & 1 deletion OptimizelySwiftSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "OptimizelySwiftSDK"
s.module_name = "Optimizely"
s.version = "3.0.0"
s.version = "3.1.0-beta"
s.summary = "Optimizely server-side testing core framework."
s.homepage = "http://developers.optimizely.com/server/reference/index.html?language=objectivec"
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }
Expand Down
41 changes: 3 additions & 38 deletions Scripts/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/bash
################################################################
# buildall.sh
# * Not really in production, but a personal script written quickly
# to automate building all the objective-c-sdk workspace schemes .
# * There aren't any tempfiles . Copied and pasted some stuff
# from our unexported_symbols.sh script.
################################################################
set -e

Expand Down Expand Up @@ -33,40 +29,9 @@ main() {
# TODO: This isn't the best, but you can supply "clean" to our command.
action="$1"
fi;
# TODO: We'll need to specify certificate for the app builds.
#xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelyiOSDemoApp -configuration Release "${action}"
#xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelyTVOSDemoApp -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKCoreiOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKCoreTVOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKDatafileManageriOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKDatafileManagerTVOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKEventDispatcheriOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKEventDispatcherTVOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOS-Universal -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOSUniversal -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKSharediOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKSharedTVOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOS-Universal -configuration Release "${action}"
# Xcode IDE is happy with OptimizelySDKTVOSUniversal , we don't know what's up with our *.sh .
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOSUniversal -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKUserProfileServiceiOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKUserProfileServiceTVOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelyiOSDemoApp -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKCoreiOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKCoreTVOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKDatafileManageriOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKDatafileManagerTVOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKEventDispatcheriOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKEventDispatcherTVOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKiOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKSharediOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKSharedTVOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKTVOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKUserProfileServiceiOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelySDKUserProfileServiceTVOSTests -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme Pods-OptimizelyTVOSDemoApp -configuration Release "${action}"

xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -configuration Release "${action}"
xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -configuration Release "${action}"
}

main
Expand Down
62 changes: 17 additions & 45 deletions Scripts/test_all.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,17 @@
#xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelyiOSDemoApp -configuration Release "${action}"
#xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelyTVOSDemoApp -configuration Release "${action}"
echo 'Testing OptimizelySDKUserProfileServiceiOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKUserProfileServiceiOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
test
echo 'Testing OptimizelySDKUserProfileServiceTVOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKUserProfileServiceTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
test
echo 'Testing OptimizelySDKSharediOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKSharediOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
test
echo 'Testing OptimizelySDKSharedTVOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKSharedTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
test
echo 'Testing OptimizelySDKCoreiOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKCoreiOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
test
echo 'Testing OptimizelySDKCoretvOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKCoreTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
test
echo 'Testing OptimizelySDKDatafileManageriOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKDatafileManageriOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
test
echo 'Testing OptimizelySDKDatafileManagerTVOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKDatafileManagerTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
test
echo 'Testing OptimizelySDKEventDispatcheriOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKEventDispatcheriOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
test
echo 'Testing OptimizelySDKEventDispatcherTVOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKEventDispatcherTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
test
echo 'Testing OptimizelySDKiOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
test
echo 'Testing OptimizelySDKiOSUniversal'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKiOSUniversal -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.2' \
test
echo 'Testing OptimizelySDKTVOS'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
test
# Xcode IDE is happy with OptimizelySDKTVOSUniversal , we don't know what's up with our *.sh .
echo 'Testing OptimizelySDKTVOSUniversal'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySDKTVOSUniversal -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' \
test
echo 'Testing OptimizelySwiftSDK-iOS (iPhone 6,OS=9.2)'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0' test
echo 'Testing OptimizelySwiftSDK-iOS (iPhone 8,OS=12.1)'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8,OS=12.1' test
echo 'Testing OptimizelySwiftSDK-iOS (iPhone SE,OS=10.0)'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone SE,OS=10.0' test
echo 'Testing OptimizelySwiftSDK-iOS (iPhone XS,OS=12.1)'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone XS,OS=12.1' test

echo 'Testing OptimizelySwiftSDK-tvOS (Apple TV 1080p,OS=9.0)'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV 1080p,OS=9.0' test
echo 'Testing OptimizelySwiftSDK-tvOS (Apple TV,OS=11.0)'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=11.0' test
echo 'Testing OptimizelySwiftSDK-tvOS (Apple TV,OS=12.1)'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.1' test
echo 'Testing OptimizelySwiftSDK-tvOS (Apple TV 4K,OS=12.1)'
xcrun xcodebuild -workspace OptimizelySDK.xcworkspace -scheme OptimizelySwiftSDK-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV 4K,OS=12.1' test
Loading