Skip to content

Commit

Permalink
Merge pull request #41 from square/shawnwelch/add-watch-3.0
Browse files Browse the repository at this point in the history
Add support for Apple Watch in CoreAardvark
  • Loading branch information
shawnwelch committed Jan 12, 2017
2 parents ace602d + 42c8e21 commit 492fcb6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Aardvark.xcodeproj/project.pbxproj
Expand Up @@ -912,6 +912,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.squareup.CoreAardvark;
PRODUCT_NAME = CoreAardvark;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos watchos watchsimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -941,6 +942,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.squareup.CoreAardvark;
PRODUCT_NAME = CoreAardvark;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos watchos watchsimulator";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
Expand Down
3 changes: 2 additions & 1 deletion CoreAardvark.podspec
@@ -1,12 +1,13 @@
Pod::Spec.new do |s|
s.name = 'CoreAardvark'
s.version = '2.0.0'
s.version = '2.1.0'
s.license = 'Apache License, Version 2.0'
s.summary = 'Aardvark is a library that makes it dead simple to create actionable bug reports. Usable by extensions.'
s.homepage = 'https://github.com/square/Aardvark'
s.authors = 'Square'
s.source = { :git => 'https://github.com/square/Aardvark.git', :tag => "CoreAardvark/#{ s.version.to_s }" }
s.ios.deployment_target = '8.0'
s.watchos.deployment_target = '3.0'
s.source_files = 'CoreAardvark/**/*.{h,m,swift}'
s.private_header_files = 'CoreAardvark/*_Testing.h', 'CoreAardvark/Private Categories/*.h'
end
3 changes: 3 additions & 0 deletions CoreAardvark/ARKLogStore.h
Expand Up @@ -57,4 +57,7 @@
/// Removes all logs. Completion handler is called on the main queue.
- (void)clearLogsWithCompletionHandler:(nullable dispatch_block_t)completionHandler;

/// Waits for all of the pending logs to distribute from the log distributor, then saves the archive. This is done automatically when platform=ios in applicationWillTerminate;, but must be done manually in platform=watchos, preferably in WKExtensionDelegate applicationWillResignActive.
- (void)waitUntilAllLogsAreConsumedAndArchiveSaved;

@end
11 changes: 9 additions & 2 deletions CoreAardvark/ARKLogStore.m
Expand Up @@ -64,7 +64,9 @@ - (nullable instancetype)initWithPersistedLogFileName:(nonnull NSString *)fileNa
_dataArchive = dataArchive;
_prefixNameWhenPrintingToConsole = YES;

#if !TARGET_OS_WATCH
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:nil];
#endif

return self;
}
Expand Down Expand Up @@ -128,12 +130,17 @@ - (void)clearLogsWithCompletionHandler:(nullable dispatch_block_t)completionHand
}
}

- (void)waitUntilAllLogsAreConsumedAndArchiveSaved;
{
[self.logDistributor waitUntilAllPendingLogsHaveBeenDistributed];
[self.dataArchive saveArchiveAndWait:YES];
}

#pragma mark - Private Methods

- (void)_applicationWillTerminate:(nullable NSNotification *)notification;
{
[self.logDistributor waitUntilAllPendingLogsHaveBeenDistributed];
[self.dataArchive saveArchiveAndWait:YES];
[self waitUntilAllLogsAreConsumedAndArchiveSaved];
}

@end

0 comments on commit 492fcb6

Please sign in to comment.