Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds WatchKit support via CocoaPods (#465)
* Adds WatchKit support via CocoaPods * Fixes missing file for watchOS * Change watchOS product name * Adds modual map for watchos * Adds carthage watch example * Adds cocoapods watch example * Update CocoaPods demo to include older watchOS version I noticed that apps using this library could not launch on older watchOS version. This adds a demo project to reproduce this, * Fix crash on < watchOS 6 This fixes the crash mentioned in the prev. commit. It removes the frameworks for watchOS from the Podspec. * Changed button name
- Loading branch information
Showing
85 changed files
with
2,931 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// ExtensionDelegate.swift | ||
// SnowplowSwiftDemoWatch WatchKit Extension | ||
// | ||
// Created by Leo Mehlig on 12.11.19. | ||
// Copyright © 2019 snowplowanalytics. All rights reserved. | ||
// | ||
|
||
import WatchKit | ||
|
||
class ExtensionDelegate: NSObject, WKExtensionDelegate { | ||
|
||
func applicationDidFinishLaunching() { | ||
// Perform any final initialization of your application. | ||
} | ||
|
||
func applicationDidBecomeActive() { | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
func applicationWillResignActive() { | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, etc. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// InterfaceController.swift | ||
// SnowplowSwiftDemoWatch WatchKit Extension | ||
// | ||
// Created by Leo Mehlig on 12.11.19. | ||
// Copyright © 2019 snowplowanalytics. All rights reserved. | ||
// | ||
|
||
import WatchKit | ||
import Foundation | ||
import SnowplowTracker | ||
|
||
class InterfaceController: WKInterfaceController, SPRequestCallback { | ||
|
||
let kAppId = "DemoAppId" | ||
let kNamespace = "DemoAppNamespace" | ||
|
||
func getTracker(_ url: String, method: SPRequestOptions) -> SPTracker { | ||
let emitter = SPEmitter.build({ (builder : SPEmitterBuilder?) -> Void in | ||
builder!.setUrlEndpoint(url) | ||
builder!.setHttpMethod(method) | ||
builder!.setCallback(self) | ||
builder!.setEmitRange(500) | ||
builder!.setEmitThreadPoolSize(20) | ||
builder!.setByteLimitPost(52000) | ||
}) | ||
let subject = SPSubject(platformContext: true, andGeoContext: false) | ||
let newTracker = SPTracker.build({ (builder : SPTrackerBuilder?) -> Void in | ||
builder!.setEmitter(emitter) | ||
builder!.setAppId(self.kAppId) | ||
builder!.setTrackerNamespace(self.kNamespace) | ||
builder!.setBase64Encoded(false) | ||
builder!.setSessionContext(true) | ||
builder!.setSubject(subject) | ||
builder!.setLifecycleEvents(true) | ||
builder!.setAutotrackScreenViews(true) | ||
builder!.setScreenContext(true) | ||
builder!.setApplicationContext(true) | ||
builder!.setExceptionEvents(true) | ||
builder!.setInstallEvent(true) | ||
}) | ||
return newTracker! | ||
} | ||
|
||
var tracker : SPTracker! | ||
|
||
|
||
override func awake(withContext context: Any?) { | ||
super.awake(withContext: context) | ||
self.tracker = self.getTracker("acme.fake.com", method: .post) | ||
// Configure interface objects here. | ||
} | ||
|
||
override func willActivate() { | ||
// This method is called when watch view controller is about to be visible to user | ||
super.willActivate() | ||
} | ||
|
||
override func didDeactivate() { | ||
// This method is called when watch view controller is no longer visible | ||
super.didDeactivate() | ||
} | ||
|
||
@IBAction func sendEvent() { | ||
DispatchQueue.global(qos: .default).async { | ||
self.tracker.emitter.setUrlEndpoint("127.0.0.1:8080") | ||
self.tracker.emitter.setHttpMethod(SPRequestOptions.post) | ||
self.tracker.emitter.setProtocol(SPProtocol.http) | ||
// Track all types of events | ||
DemoUtils.trackAll(self.tracker) | ||
} | ||
} | ||
|
||
func onSuccess(withCount successCount: Int) { | ||
print("Success: \(successCount)") | ||
} | ||
|
||
func onFailure(withCount failureCount: Int, successCount: Int) { | ||
print("Failure: \(failureCount), Success: \(successCount)") | ||
} | ||
|
||
} |
391 changes: 390 additions & 1 deletion
391
Examples/SnowplowSwiftCarthageDemo/SnowplowSwiftDemo.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...wiftCarthageDemo/SnowplowSwiftDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
...Demo/SnowplowSwiftDemoWatch WatchKit App/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"size" : "24x24", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "notificationCenter", | ||
"subtype" : "38mm" | ||
}, | ||
{ | ||
"size" : "27.5x27.5", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "notificationCenter", | ||
"subtype" : "42mm" | ||
}, | ||
{ | ||
"size" : "29x29", | ||
"idiom" : "watch", | ||
"role" : "companionSettings", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "29x29", | ||
"idiom" : "watch", | ||
"role" : "companionSettings", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"size" : "40x40", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "appLauncher", | ||
"subtype" : "38mm" | ||
}, | ||
{ | ||
"size" : "44x44", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "appLauncher", | ||
"subtype" : "40mm" | ||
}, | ||
{ | ||
"size" : "50x50", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "appLauncher", | ||
"subtype" : "44mm" | ||
}, | ||
{ | ||
"size" : "86x86", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "quickLook", | ||
"subtype" : "38mm" | ||
}, | ||
{ | ||
"size" : "98x98", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "quickLook", | ||
"subtype" : "42mm" | ||
}, | ||
{ | ||
"size" : "108x108", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "quickLook", | ||
"subtype" : "44mm" | ||
}, | ||
{ | ||
"idiom" : "watch-marketing", | ||
"size" : "1024x1024", | ||
"scale" : "1x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...owplowSwiftCarthageDemo/SnowplowSwiftDemoWatch WatchKit App/Assets.xcassets/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...plowSwiftCarthageDemo/SnowplowSwiftDemoWatch WatchKit App/Base.lproj/Interface.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="15505" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc"> | ||
<device id="watch38"/> | ||
<dependencies> | ||
<deployment identifier="watchOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="15501"/> | ||
</dependencies> | ||
<scenes> | ||
<!--Interface Controller--> | ||
<scene sceneID="aou-V4-d1y"> | ||
<objects> | ||
<controller id="AgC-eL-Hgc" customClass="InterfaceController" customModule="SnowplowSwiftDemoWatch_WatchKit_App" customModuleProvider="target"> | ||
<items> | ||
<button width="1" alignment="left" title="Send Event" id="lfB-HY-hyg"> | ||
<connections> | ||
<action selector="sendEvent" destination="AgC-eL-Hgc" id="ZcE-E4-Uob"/> | ||
</connections> | ||
</button> | ||
</items> | ||
</controller> | ||
</objects> | ||
<point key="canvasLocation" x="34" y="31"/> | ||
</scene> | ||
</scenes> | ||
</document> |
33 changes: 33 additions & 0 deletions
33
Examples/SnowplowSwiftCarthageDemo/SnowplowSwiftDemoWatch WatchKit App/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>SnowplowSwiftDemoWatch WatchKit App</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
</array> | ||
<key>WKCompanionAppBundleIdentifier</key> | ||
<string>com.snowplowanalytics.SnowplowSwiftDemo</string> | ||
<key>WKWatchKitApp</key> | ||
<true/> | ||
</dict> | ||
</plist> |
28 changes: 28 additions & 0 deletions
28
...it Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...ftDemoWatch WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"assets" : [ | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Circular.imageset", | ||
"role" : "circular" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Extra Large.imageset", | ||
"role" : "extra-large" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Graphic Bezel.imageset", | ||
"role" : "graphic-bezel" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Graphic Circular.imageset", | ||
"role" : "graphic-circular" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Graphic Corner.imageset", | ||
"role" : "graphic-corner" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Graphic Large Rectangular.imageset", | ||
"role" : "graphic-large-rectangular" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Modular.imageset", | ||
"role" : "modular" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Utilitarian.imageset", | ||
"role" : "utilitarian" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">161" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">183" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Oops, something went wrong.