Skip to content

Commit

Permalink
Merge branch 'release/1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
defagos committed Sep 28, 2018
2 parents 3686dd6 + 44fd74b commit 45187b4
Show file tree
Hide file tree
Showing 34 changed files with 2,285 additions and 54 deletions.
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Carthage
xcuserdata
.DS_Store
report.xml
test_output

*.xcscmblueprint
xcuserdata

/archive
/build

/Carthage

/fastlane/report.xml
/fastlane/test_output
20 changes: 20 additions & 0 deletions Framework/Resources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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>en</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>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions Framework/Sources/Helpers/NSBundle+SRGDiagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface NSBundle (SRGDiagnostics)

/**
* The SRGDiagnostics resource bundle.
* The SRG Diagnostics resource bundle.
*/
+ (NSBundle *)srg_diagnosticsBundle;
@property (class, nonatomic, readonly) NSBundle *srg_diagnosticsBundle;

@end

Expand Down
4 changes: 3 additions & 1 deletion Framework/Sources/Helpers/NSBundle+SRGDiagnostics.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ + (instancetype)srg_diagnosticsBundle
static NSBundle *s_bundle;
static dispatch_once_t s_onceToken;
dispatch_once(&s_onceToken, ^{
s_bundle = [NSBundle bundleForClass:[SRGDiagnosticsService class]];
NSString *bundlePath = [[NSBundle bundleForClass:SRGDiagnosticsService.class].bundlePath stringByAppendingPathComponent:@"SRGDiagnostics.bundle"];
s_bundle = [NSBundle bundleWithPath:bundlePath];
NSAssert(s_bundle, @"Please add SRGDiagnostics.bundle to your project resources");
});
return s_bundle;
}
Expand Down
20 changes: 20 additions & 0 deletions Framework/Sources/Helpers/NSTimer+SRGDiagnostics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSTimer (SRGDiagnostics)

/**
* Create a block-based timer (a feature only available since iOS 10), scheduled with common run loop modes.
*/
+ (NSTimer *)srgdiagnostics_timerWithTimeInterval:(NSTimeInterval)interval repeats:(BOOL)repeats block:(void (^)(NSTimer *timer))block;

@end

NS_ASSUME_NONNULL_END
30 changes: 30 additions & 0 deletions Framework/Sources/Helpers/NSTimer+SRGDiagnostics.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import "NSTimer+SRGDiagnostics.h"

#import "SRGDiagnosticsTimerTarget.h"

@implementation NSTimer (SRGDiagnostics)

+ (NSTimer *)srgdiagnostics_timerWithTimeInterval:(NSTimeInterval)interval repeats:(BOOL)repeats block:(void (^)(NSTimer * _Nonnull timer))block
{
NSTimer *timer = nil;

if (@available(iOS 10, *)) {
timer = [self timerWithTimeInterval:interval repeats:repeats block:block];
}
else {
// Do not use self as target, since this would lead to subtle issues when the timer is deallocated
SRGDiagnosticsTimerTarget *target = [[SRGDiagnosticsTimerTarget alloc] initWithBlock:block];
timer = [self timerWithTimeInterval:interval target:target selector:@selector(fire:) userInfo:nil repeats:repeats];
}

[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
return timer;
}

@end
29 changes: 29 additions & 0 deletions Framework/Sources/Helpers/SRGDiagnosticsTimerTarget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* Helper class used as target for a timer.
*/
// TODO: Remove when iOS 10 is the minimum required version
@interface SRGDiagnosticsTimerTarget : NSObject

/**
* Create the target with the specified to be executed when `-fire:` is called.
*/
- (instancetype)initWithBlock:(nullable void (^)(NSTimer *timer))block;

/**
* Execute the attached block on behalf of the specified timer.
*/
- (void)fire:(NSTimer *)timer;

@end

NS_ASSUME_NONNULL_END
30 changes: 30 additions & 0 deletions Framework/Sources/Helpers/SRGDiagnosticsTimerTarget.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import "SRGDiagnosticsTimerTarget.h"

@interface SRGDiagnosticsTimerTarget ()

@property (nonatomic, copy) void (^block)(NSTimer *);

@end

@implementation SRGDiagnosticsTimerTarget

- (instancetype)initWithBlock:(void (^)(NSTimer * _Nonnull))block
{
if (self = [super init]) {
self.block = block;
}
return self;
}

- (void)fire:(NSTimer *)timer
{
self.block ? self.block(timer) : nil;
}

@end
15 changes: 0 additions & 15 deletions Framework/Sources/Player/SRGDiagnosticsService.h

This file was deleted.

11 changes: 0 additions & 11 deletions Framework/Sources/Player/SRGDiagnosticsService.m

This file was deleted.

51 changes: 51 additions & 0 deletions Framework/Sources/SRGDiagnosticInformation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Copyright (c) SRG SSR. All rights reserved.
//
// License information is available from the LICENSE file.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* Diagnostic information.
*/
@interface SRGDiagnosticInformation : NSObject <NSCopying>

/**
* Associate primitive values with keys.
*/
- (void)setBool:(BOOL)value forKey:(NSString *)key;
- (void)setInteger:(NSInteger)value forKey:(NSString *)key;
- (void)setFloat:(float)value forKey:(NSString *)key;
- (void)setDouble:(double)value forKey:(NSString *)key;

/**
* Associate objects with keys. Setting `nil` removes the associated entry, if any.
*/
- (void)setString:(nullable NSString *)string forKey:(NSString *)key;
- (void)setNumber:(nullable NSNumber *)number forKey:(NSString *)key;
- (void)setURL:(nullable NSURL *)URL forKey:(NSString *)key;

/**
* Start / stop a time measurement, saving the associated value under the specified key.
*
* @discussion If a measurement is not stopped, it will be ignored when the report is submitted.
*/
- (void)startTimeMeasurementForKey:(NSString *)key;
- (void)stopTimeMeasurementForKey:(NSString *)key;

/**
* Return nested information under the specified key.
*/
- (SRGDiagnosticInformation *)informationForKey:(NSString *)key;

/**
* Return report information as a dictionary serializable to JSON.
*/
- (NSDictionary<NSString *, id> *)JSONDictionary;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 45187b4

Please sign in to comment.