Skip to content

Commit 5301725

Browse files
Add support for watchOS (#390)
1 parent fceb136 commit 5301725

File tree

22 files changed

+1323
-14
lines changed

22 files changed

+1323
-14
lines changed

DemoSwiftApp/DemoSwiftApp.xcodeproj/project.pbxproj

Lines changed: 458 additions & 1 deletion
Large diffs are not rendered by default.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1240"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "75C71C4D25E45A960084187E"
18+
BuildableName = "DemoSwiftwatchOS WatchKit App.app"
19+
BlueprintName = "DemoSwiftwatchOS WatchKit App"
20+
ReferencedContainer = "container:DemoSwiftApp.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
<BuildActionEntry
24+
buildForTesting = "YES"
25+
buildForRunning = "YES"
26+
buildForProfiling = "YES"
27+
buildForArchiving = "YES"
28+
buildForAnalyzing = "YES">
29+
<BuildableReference
30+
BuildableIdentifier = "primary"
31+
BlueprintIdentifier = "75C71C4A25E45A960084187E"
32+
BuildableName = "DemoSwiftwatchOS.app"
33+
BlueprintName = "DemoSwiftwatchOS"
34+
ReferencedContainer = "container:DemoSwiftApp.xcodeproj">
35+
</BuildableReference>
36+
</BuildActionEntry>
37+
</BuildActionEntries>
38+
</BuildAction>
39+
<TestAction
40+
buildConfiguration = "Debug"
41+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
42+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
shouldUseLaunchSchemeArgsEnv = "YES">
44+
<Testables>
45+
</Testables>
46+
</TestAction>
47+
<LaunchAction
48+
buildConfiguration = "Debug"
49+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
50+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
51+
launchStyle = "0"
52+
useCustomWorkingDirectory = "NO"
53+
ignoresPersistentStateOnLaunch = "NO"
54+
debugDocumentVersioning = "YES"
55+
debugServiceExtension = "internal"
56+
allowLocationSimulation = "YES">
57+
<RemoteRunnable
58+
runnableDebuggingMode = "2"
59+
BundleIdentifier = "com.apple.Carousel"
60+
RemotePath = "/DemoSwiftwatchOS WatchKit App">
61+
<BuildableReference
62+
BuildableIdentifier = "primary"
63+
BlueprintIdentifier = "75C71C4D25E45A960084187E"
64+
BuildableName = "DemoSwiftwatchOS WatchKit App.app"
65+
BlueprintName = "DemoSwiftwatchOS WatchKit App"
66+
ReferencedContainer = "container:DemoSwiftApp.xcodeproj">
67+
</BuildableReference>
68+
</RemoteRunnable>
69+
</LaunchAction>
70+
<ProfileAction
71+
buildConfiguration = "Release"
72+
shouldUseLaunchSchemeArgsEnv = "YES"
73+
savedToolIdentifier = ""
74+
useCustomWorkingDirectory = "NO"
75+
debugDocumentVersioning = "YES">
76+
<RemoteRunnable
77+
runnableDebuggingMode = "2"
78+
BundleIdentifier = "com.apple.Carousel"
79+
RemotePath = "/DemoSwiftwatchOS WatchKit App">
80+
<BuildableReference
81+
BuildableIdentifier = "primary"
82+
BlueprintIdentifier = "75C71C4D25E45A960084187E"
83+
BuildableName = "DemoSwiftwatchOS WatchKit App.app"
84+
BlueprintName = "DemoSwiftwatchOS WatchKit App"
85+
ReferencedContainer = "container:DemoSwiftApp.xcodeproj">
86+
</BuildableReference>
87+
</RemoteRunnable>
88+
<MacroExpansion>
89+
<BuildableReference
90+
BuildableIdentifier = "primary"
91+
BlueprintIdentifier = "75C71C4D25E45A960084187E"
92+
BuildableName = "DemoSwiftwatchOS WatchKit App.app"
93+
BlueprintName = "DemoSwiftwatchOS WatchKit App"
94+
ReferencedContainer = "container:DemoSwiftApp.xcodeproj">
95+
</BuildableReference>
96+
</MacroExpansion>
97+
</ProfileAction>
98+
<AnalyzeAction
99+
buildConfiguration = "Debug">
100+
</AnalyzeAction>
101+
<ArchiveAction
102+
buildConfiguration = "Release"
103+
revealArchiveInOrganizer = "YES">
104+
</ArchiveAction>
105+
</Scheme>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "watch",
5+
"role" : "notificationCenter",
6+
"scale" : "2x",
7+
"size" : "24x24",
8+
"subtype" : "38mm"
9+
},
10+
{
11+
"idiom" : "watch",
12+
"role" : "notificationCenter",
13+
"scale" : "2x",
14+
"size" : "27.5x27.5",
15+
"subtype" : "42mm"
16+
},
17+
{
18+
"idiom" : "watch",
19+
"role" : "companionSettings",
20+
"scale" : "2x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "watch",
25+
"role" : "companionSettings",
26+
"scale" : "3x",
27+
"size" : "29x29"
28+
},
29+
{
30+
"idiom" : "watch",
31+
"role" : "appLauncher",
32+
"scale" : "2x",
33+
"size" : "40x40",
34+
"subtype" : "38mm"
35+
},
36+
{
37+
"idiom" : "watch",
38+
"role" : "appLauncher",
39+
"scale" : "2x",
40+
"size" : "44x44",
41+
"subtype" : "40mm"
42+
},
43+
{
44+
"idiom" : "watch",
45+
"role" : "appLauncher",
46+
"scale" : "2x",
47+
"size" : "50x50",
48+
"subtype" : "44mm"
49+
},
50+
{
51+
"idiom" : "watch",
52+
"role" : "quickLook",
53+
"scale" : "2x",
54+
"size" : "86x86",
55+
"subtype" : "38mm"
56+
},
57+
{
58+
"idiom" : "watch",
59+
"role" : "quickLook",
60+
"scale" : "2x",
61+
"size" : "98x98",
62+
"subtype" : "42mm"
63+
},
64+
{
65+
"idiom" : "watch",
66+
"role" : "quickLook",
67+
"scale" : "2x",
68+
"size" : "108x108",
69+
"subtype" : "44mm"
70+
},
71+
{
72+
"idiom" : "watch-marketing",
73+
"scale" : "1x",
74+
"size" : "1024x1024"
75+
}
76+
],
77+
"info" : {
78+
"author" : "xcode",
79+
"version" : 1
80+
}
81+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="11134" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="11055"/>
6+
</dependencies>
7+
<scenes>
8+
<!--Interface Controller-->
9+
<scene sceneID="aou-V4-d1y">
10+
<objects>
11+
<controller id="AgC-eL-Hgc" customClass="InterfaceController" customModuleProvider="target"/>
12+
</objects>
13+
</scene>
14+
</scenes>
15+
</document>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>DemoSwiftwatchOS WatchKit App</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>UISupportedInterfaceOrientations</key>
24+
<array>
25+
<string>UIInterfaceOrientationPortrait</string>
26+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
27+
</array>
28+
<key>WKWatchKitApp</key>
29+
<true/>
30+
</dict>
31+
</plist>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/****************************************************************************
2+
* Copyright 2021, Optimizely, Inc. and contributors *
3+
* *
4+
* Licensed under the Apache License, Version 2.0 (the "License"); *
5+
* you may not use this file except in compliance with the License. *
6+
* You may obtain a copy of the License at *
7+
* *
8+
* http://www.apache.org/licenses/LICENSE-2.0 *
9+
* *
10+
* Unless required by applicable law or agreed to in writing, software *
11+
* distributed under the License is distributed on an "AS IS" BASIS, *
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13+
* See the License for the specific language governing permissions and *
14+
* limitations under the License. *
15+
***************************************************************************/
16+
17+
import Optimizely
18+
import WatchKit
19+
20+
class ExtensionDelegate: NSObject, WKExtensionDelegate {
21+
let logLevel = OptimizelyLogLevel.debug
22+
let sdkKey = "FCnSegiEkRry9rhVMroit4"
23+
var optimizely: OptimizelyClient!
24+
25+
func applicationDidFinishLaunching() {
26+
optimizely = OptimizelyClient(sdkKey: sdkKey, defaultLogLevel: logLevel)
27+
optimizely.start { result in
28+
switch result {
29+
case .failure(let error):
30+
print("Optimizely SDK initiliazation failed: \(error)")
31+
case .success:
32+
print("Optimizely SDK initialized successfully!")
33+
}
34+
}
35+
}
36+
37+
func applicationDidBecomeActive() {
38+
WatchBackgroundNotifier.applicationDidBecomeActive()
39+
}
40+
41+
func applicationDidEnterBackground() {
42+
WatchBackgroundNotifier.applicationDidEnterBackground()
43+
}
44+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>DemoSwiftwatchOS WatchKit Extension</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>NSExtension</key>
24+
<dict>
25+
<key>NSExtensionAttributes</key>
26+
<dict>
27+
<key>WKAppBundleIdentifier</key>
28+
<string>com.optimizely.DemoSwiftwatchOS.watchkitapp</string>
29+
</dict>
30+
<key>NSExtensionPointIdentifier</key>
31+
<string>com.apple.watchkit</string>
32+
</dict>
33+
<key>WKExtensionDelegateClassName</key>
34+
<string>$(PRODUCT_MODULE_NAME).ExtensionDelegate</string>
35+
<key>WKWatchOnly</key>
36+
<true/>
37+
</dict>
38+
</plist>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/****************************************************************************
2+
* Copyright 2021, Optimizely, Inc. and contributors *
3+
* *
4+
* Licensed under the Apache License, Version 2.0 (the "License"); *
5+
* you may not use this file except in compliance with the License. *
6+
* You may obtain a copy of the License at *
7+
* *
8+
* http://www.apache.org/licenses/LICENSE-2.0 *
9+
* *
10+
* Unless required by applicable law or agreed to in writing, software *
11+
* distributed under the License is distributed on an "AS IS" BASIS, *
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13+
* See the License for the specific language governing permissions and *
14+
* limitations under the License. *
15+
***************************************************************************/
16+
17+
18+
import WatchKit
19+
import Foundation
20+
21+
22+
class InterfaceController: WKInterfaceController {
23+
24+
override func awake(withContext context: Any?) {
25+
// Configure interface objects here.
26+
}
27+
28+
override func willActivate() {
29+
// This method is called when watch view controller is about to be visible to user
30+
}
31+
32+
override func didDeactivate() {
33+
// This method is called when watch view controller is no longer visible
34+
}
35+
36+
}

OptimizelySwiftSDK.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ Pod::Spec.new do |s|
22
s.name = "OptimizelySwiftSDK"
33
s.module_name = "Optimizely"
44
s.version = "3.7.0"
5-
s.summary = "Optimizely experiment framework for iOS/tvOS"
5+
s.summary = "Optimizely experiment framework for iOS/tvOS/watchOS"
66
s.homepage = "https://docs.developers.optimizely.com/full-stack/docs"
77
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }
88
s.author = { "Optimizely" => "support@optimizely.com" }
99
s.ios.deployment_target = "10.0"
1010
s.tvos.deployment_target = "10.0"
1111
s.osx.deployment_target = "10.14"
12+
s.watchos.deployment_target = "3.0"
1213
s.source = {
1314
:git => "https://github.com/optimizely/swift-sdk.git",
1415
:tag => "v"+s.version.to_s

0 commit comments

Comments
 (0)