Skip to content
Open
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _None._

### New Features

_None._
- The library can now be used in tvOS targets. [#336]

### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PackageDescription

let package = Package(
name: "AutomatticTracksiOS",
platforms: [.macOS(.v10_14), .iOS(.v15)],
platforms: [.macOS(.v10_14), .iOS(.v15), .tvOS(.v15)],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is v15 due to Sentry or other dependencies? It's quite old

Image

https://developer.apple.com/documentation/packagedescription/supportedplatform/tvosversion

Having said that, so are the macOS and iOS versions, so maybe we can roll with it and update in a dedicated follow up for all of them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just kept it inline with the other platforms. To be fair if it's compatible with that version I don't see a reason to push to a more recent version.
Regarding Sentry, will we need to change something to make it use a specific tvOs version of it?

products: [
.library(
name: "AutomatticTracks",
Expand Down
20 changes: 14 additions & 6 deletions Sources/Model/ObjC/Common/TracksDeviceInformation.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#if TARGET_OS_WATCH
#import <WatchKit/WatchKit.h>
#elif TARGET_OS_TV
@import UIDeviceIdentifier;
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "UIApplication+Extensions.h"
#elif TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
@import UIDeviceIdentifier;
Expand All @@ -23,9 +28,10 @@ @interface TracksDeviceInformation ()
@property (nonatomic, assign) BOOL isReachableByWiFi;
@property (nonatomic, assign) BOOL isReachableByWWAN;

#if TARGET_OS_IPHONE && !TARGET_OS_WATCH
@property (nonatomic, assign) UIDeviceOrientation lastKnownDeviceOrientation;
@property (nonatomic, strong) NSString *lastKnownPreferredContentSizeCategory;

#if TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV
@property (nonatomic, assign) UIDeviceOrientation lastKnownDeviceOrientation;
#endif

@end
Expand All @@ -44,7 +50,7 @@ - (instancetype)init

- (void)preloadDeviceProperties
{
#if TARGET_OS_IPHONE && !TARGET_OS_WATCH
#if TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV
void (^preload)(void) = ^(void) {
self.lastKnownDeviceOrientation = UIDevice.currentDevice.orientation;
self.lastKnownPreferredContentSizeCategory = UIApplication.sharedIfAvailable.preferredContentSizeCategory;
Expand Down Expand Up @@ -73,7 +79,7 @@ - (NSString *)currentNetworkOperator
{
#if TARGET_OS_SIMULATOR
return @"Carrier (Simulator)";
#elif TARGET_OS_WATCH
#elif TARGET_OS_WATCH || TARGET_OS_TV
return @"Not Applicable";
#elif TARGET_OS_IPHONE
CTTelephonyNetworkInfo *netInfo = [CTTelephonyNetworkInfo new];
Expand Down Expand Up @@ -168,6 +174,8 @@ - (NSString *)version
-(BOOL)isAppleWatchConnected{
#if TARGET_OS_WATCH
return YES; // We're running on the watch itself
#elif TARGET_OS_TV
return NO; // We're running on tvOS
#elif TARGET_OS_IPHONE
return [[WatchSessionManager shared] hasBeenPreviouslyPaired];
#else // Mac
Expand All @@ -194,7 +202,7 @@ -(BOOL)isVoiceOverEnabled{
}

-(NSString *)orientation{
#if TARGET_OS_WATCH
#if TARGET_OS_WATCH || TARGET_OS_TV
return @"Unknown";
#elif TARGET_OS_IPHONE
UIDeviceOrientation orientation = [self deviceOrientation];
Expand All @@ -213,7 +221,7 @@ -(NSString *)orientation{

#pragma mark - Calls that need to run on the main thread

#if TARGET_OS_IPHONE && !TARGET_OS_WATCH
#if TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV
// This method was created because UIDevice.currentDevice.orientation should only
// be called from the main thread.
//
Expand Down
8 changes: 4 additions & 4 deletions Sources/Model/ObjC/Common/WatchSessionManager.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "WatchSessionManager.h"

#if TARGET_OS_IPHONE && !TARGET_OS_WATCH
#if TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV
#import <WatchConnectivity/WatchConnectivity.h>

@interface WatchSessionManager()<WCSessionDelegate>
Expand Down Expand Up @@ -34,7 +34,7 @@ - (instancetype)init {
return self;
}

#if TARGET_OS_IPHONE && !TARGET_OS_WATCH
#if TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV
if([WCSession isSupported]){
self.session = [WCSession defaultSession];

Expand All @@ -54,7 +54,7 @@ - (instancetype)init {
return self;
}

#if TARGET_OS_IPHONE && !TARGET_OS_WATCH
#if TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV
- (void)setHasBeenPairedIfPossibleWithSession:(nonnull WCSession *)session {
if(session.paired){
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"watch-has-been-previously-paired"];
Expand All @@ -69,7 +69,7 @@ - (BOOL)hasBeenPreviouslyPaired{

#pragma mark – WCSessionDelegate

#if TARGET_OS_IPHONE && !TARGET_OS_WATCH
#if TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV
- (void)session:(nonnull WCSession *)session activationDidCompleteWithState:(WCSessionActivationState)activationState error:(nullable NSError *)error {

[self setHasBeenPairedIfPossibleWithSession:session];
Expand Down
2 changes: 1 addition & 1 deletion Sources/Remote Logging/Crash Logging/CrashLogging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class CrashLogging {
// input `SamplingContext` down the chain.
NSNumber(value: self.dataProvider.tracesSampler())
}
#if !os(watchOS)
#if !os(watchOS) && !os(tvOS)
options.configureProfiling = { [weak self] in
guard let self else { return }
$0.sessionSampleRate = Float(self.dataProvider.profilingRate)
Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Crash Logging/CrashLoggingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Sentry
import AutomatticRemoteLogging
#endif

@available(iOS 13.0, OSX 10.15, *)
@available(iOS 13.0, OSX 10.15, tvOS 15.0, *)
public struct CrashLoggingView: View {

@State
Expand Down
18 changes: 9 additions & 9 deletions TracksDemo/TracksDemo Mac/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="24506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24506"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -746,7 +746,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vpk-HH-O92">
<rect key="frame" x="18" y="254" width="284" height="24"/>
<rect key="frame" x="20" y="253" width="280" height="24"/>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="ufe-cz-hLx">
<font key="font" metaFont="system"/>
<segments>
Expand All @@ -759,7 +759,7 @@
</connections>
</segmentedControl>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LvN-NF-nf3">
<rect key="frame" x="108" y="184" width="105" height="32"/>
<rect key="frame" x="113" y="193" width="95" height="24"/>
<buttonCell key="cell" type="push" title="Track Event" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="sqO-cl-mSO">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -769,7 +769,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ouy-1L-hFs">
<rect key="frame" x="35" y="152" width="251" height="32"/>
<rect key="frame" x="40" y="157" width="240" height="24"/>
<buttonCell key="cell" type="push" title="Track Event with Custom Properties" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="hVq-4U-pxP">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -779,7 +779,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Sfw-Lf-eez">
<rect key="frame" x="89" y="120" width="142" height="32"/>
<rect key="frame" x="94" y="121" width="132" height="24"/>
<buttonCell key="cell" type="push" title="Crash Application" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="5eH-PR-7If">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -789,10 +789,10 @@
</connections>
</button>
<progressIndicator wantsLayer="YES" maxValue="100" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="HZk-XH-bST">
<rect key="frame" x="20" y="35" width="280" height="20"/>
<rect key="frame" x="20" y="36" width="280" height="20"/>
</progressIndicator>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="GNq-5F-iyf">
<rect key="frame" x="66" y="61" width="187" height="18"/>
<rect key="frame" x="69" y="64" width="182" height="32"/>
<buttonCell key="cell" type="check" title="Automatically Send Events" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="ZmD-FN-bch">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
Expand All @@ -801,7 +801,7 @@
<action selector="automaticallySendEventsToggled:" target="XfG-lQ-9wD" id="ERn-PC-uPp"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FVy-Mk-HhH">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FVy-Mk-HhH">
<rect key="frame" x="18" y="20" width="284" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Number of events queued: 0" id="zyy-qg-Dw6">
<font key="font" metaFont="system"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"images" : [
{
"idiom" : "tv"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"layers" : [
{
"filename" : "Front.imagestacklayer"
},
{
"filename" : "Middle.imagestacklayer"
},
{
"filename" : "Back.imagestacklayer"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"images" : [
{
"idiom" : "tv"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"images" : [
{
"idiom" : "tv"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"layers" : [
{
"filename" : "Front.imagestacklayer"
},
{
"filename" : "Middle.imagestacklayer"
},
{
"filename" : "Back.imagestacklayer"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"idiom" : "tv",
"scale" : "1x"
},
{
"idiom" : "tv",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading