Skip to content

Commit

Permalink
Support for iOS 9, Xcode 7, and Swift 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwe-apple committed Jun 9, 2015
1 parent 1e67f88 commit 6ee6c36
Show file tree
Hide file tree
Showing 69 changed files with 606 additions and 389 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Getting Started<a name="gettingstarted"></a>
Requirements
------------

The primary ResearchKit framework codebase supports iOS and requires Xcode 6.3
The primary ResearchKit framework codebase supports iOS and requires Xcode 7.0
or newer. The ResearchKit framework has a Base SDK version of 8.0, meaning that apps
using the ResearchKit framework can run on devices with iOS 8.0 or newer.

Expand Down
9 changes: 8 additions & 1 deletion ResearchKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
B1A860F61A9693C400EA57B7 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B1A860E81A9693C400EA57B7 /* [email protected] */; };
B1A860F71A9693C400EA57B7 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B1A860E91A9693C400EA57B7 /* [email protected] */; };
B1C0F4E41A9BA65F0022C153 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B1C0F4E11A9BA65F0022C153 /* Localizable.strings */; };
B1C7955E1A9FBF04007279BA /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B1C7955D1A9FBF04007279BA /* HealthKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
B1C7955E1A9FBF04007279BA /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B1C7955D1A9FBF04007279BA /* HealthKit.framework */; settings = {ATTRIBUTES = (Required, ); }; };
B8760F2B1AFBEFB0007FA16F /* ORKScaleRangeDescriptionLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = B8760F291AFBEFB0007FA16F /* ORKScaleRangeDescriptionLabel.h */; };
B8760F2C1AFBEFB0007FA16F /* ORKScaleRangeDescriptionLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = B8760F2A1AFBEFB0007FA16F /* ORKScaleRangeDescriptionLabel.m */; };
BC01B0FB1B0EB99700863803 /* ORKTintedImageView_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = BC01B0FA1B0EB99700863803 /* ORKTintedImageView_Internal.h */; };
Expand Down Expand Up @@ -2390,6 +2390,7 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
Expand All @@ -2407,6 +2408,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = 1;
TOOLCHAINS = default;
};
name = Debug;
};
Expand Down Expand Up @@ -2437,6 +2439,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = 1;
TOOLCHAINS = default;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -2461,6 +2464,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.apple.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -2482,6 +2486,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.apple.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down Expand Up @@ -2509,6 +2514,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MODULEMAP_FILE = ResearchKit/module.modulemap;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "apple.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = ResearchKit;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -2536,6 +2542,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MODULEMAP_FILE = ResearchKit/module.modulemap;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "apple.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = ResearchKit;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.8">
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down Expand Up @@ -48,6 +48,8 @@
ReferencedContainer = "container:ResearchKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand Down
6 changes: 4 additions & 2 deletions ResearchKit.xcodeproj/xcshareddata/xcschemes/docs.xcscheme
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.8">
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down Expand Up @@ -29,6 +29,8 @@
buildConfiguration = "Debug">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand Down
6 changes: 4 additions & 2 deletions ResearchKit/ActiveTasks/ORKActiveStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#import <ResearchKit/ORKDefines.h>
#import <ResearchKit/ORKStep.h>
#import <UIKit/UIKit.h>
#import <HealthKit/HealthKit.h>

@class ORKRecorderConfiguration;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -191,7 +193,7 @@ The default value of this property is `NO`.
See also: `ORKRecorderConfiguration` and `ORKRecorder`.
*/
@property (nonatomic, copy, nullable) NSArray *recorderConfigurations;
@property (nonatomic, copy, nullable) NSArray<ORKRecorderConfiguration *> *recorderConfigurations;

/**
The set of HealthKit types the step requests for reading. (read-only)
Expand All @@ -203,7 +205,7 @@ The default value of this property is `NO`.
By default, the property scans the recorders and collates the HealthKit
types the recorders require. Subclasses may override this implementation.
*/
@property (nonatomic, readonly, nullable) NSSet *requestedHealthKitTypesForReading;
@property (nonatomic, readonly, nullable) NSSet<HKObjectType *> *requestedHealthKitTypesForReading;

@end

Expand Down
6 changes: 3 additions & 3 deletions ResearchKit/ActiveTasks/ORKActiveStep.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ - (BOOL)isEqual:(id)object {
(self.shouldUseNextAsSkipButton == castObject.shouldUseNextAsSkipButton));
}

- (NSSet *)requestedHealthKitTypesForReading {
NSMutableSet *set = [NSMutableSet set];
- (NSSet<HKObjectType *> *)requestedHealthKitTypesForReading {
NSMutableSet<HKObjectType *> *set = [NSMutableSet set];
for (ORKRecorderConfiguration *config in self.recorderConfigurations) {
NSSet *subset = [config requestedHealthKitTypesForReading];
NSSet<HKObjectType *> *subset = [config requestedHealthKitTypesForReading];
if (subset) {
[set unionSet:subset];
}
Expand Down
12 changes: 8 additions & 4 deletions ResearchKit/ActiveTasks/ORKDataLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ ORK_CLASS_AVAILABLE
*/
+ (ORKDataLogger *)JSONDataLoggerWithDirectory:(NSURL *)url logName:(NSString *)logName delegate:(nullable id<ORKDataLoggerDelegate>)delegate;

- (instancetype)init NS_UNAVAILABLE;

/**
Returns an initialized data logger using the specified URL, log name, formatter, and delegate.
Expand Down Expand Up @@ -263,7 +265,7 @@ ORK_CLASS_AVAILABLE
@return `YES` if removing the files succeeded; otherwise, `NO`.
*/
- (BOOL)removeUploadedFiles:(NSArray *)fileURLs withError:(NSError * __nullable __autoreleasing *)error;
- (BOOL)removeUploadedFiles:(NSArray<NSURL *> *)fileURLs withError:(NSError * __nullable __autoreleasing *)error;

/**
Removes all files managed by this logger (files that have the `logName` prefix).
Expand Down Expand Up @@ -423,6 +425,8 @@ ORK_CLASS_AVAILABLE
ORK_CLASS_AVAILABLE
@interface ORKDataLoggerManager : NSObject <ORKDataLoggerDelegate>

- (instancetype)init NS_UNAVAILABLE;

/**
Returns an initialized data logger manager using the specified directory and delegate.
Expand Down Expand Up @@ -489,7 +493,7 @@ ORK_CLASS_AVAILABLE
- (void)removeDataLogger:(ORKDataLogger *)logger;

/// Returns the set of log names of the data loggers managed by this object.
- (NSArray *)logNames;
- (NSArray<NSString *> *)logNames;

/**
Enumerates all the logs that need upload across all data loggers, sorted from oldest to first.
Expand All @@ -514,7 +518,7 @@ ORK_CLASS_AVAILABLE
@return `YES` if the operation succeeds; otherwise, `NO`.
*/
- (BOOL)unmarkUploadedFiles:(NSArray *)fileURLs error:(NSError * __nullable __autoreleasing *)error;
- (BOOL)unmarkUploadedFiles:(NSArray<NSURL *> *)fileURLs error:(NSError * __nullable __autoreleasing *)error;

/**
Removes a set of uploaded files.
Expand All @@ -528,7 +532,7 @@ ORK_CLASS_AVAILABLE
@return `YES` if the operation succeeds; otherwise, `NO`.
*/
- (BOOL)removeUploadedFiles:(NSArray *)fileURLs error:(NSError * __nullable __autoreleasing *)error;
- (BOOL)removeUploadedFiles:(NSArray<NSURL *> *)fileURLs error:(NSError * __nullable __autoreleasing *)error;

/**
Removes old and uploaded logs to bring total bytes down to a threshold.
Expand Down
30 changes: 21 additions & 9 deletions ResearchKit/ActiveTasks/ORKDataLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ + (ORKDataLogger *)JSONDataLoggerWithDirectory:(NSURL *)url logName:(NSString *)
return [[ORKDataLogger alloc] initWithDirectory:url logName:logName formatter:[ORKJSONLogFormatter new] delegate:delegate];
}


- (instancetype)init {
ORKThrowMethodUnavailableException();
return nil;
}

- (instancetype)initWithDirectory:(NSURL *)url logName:(NSString *)logName formatter:(ORKLogFormatter *)formatter delegate:(id<ORKDataLoggerDelegate>)delegate {
self = [super init];
if (self) {
Expand Down Expand Up @@ -626,7 +632,7 @@ - (BOOL)markFileUploaded:(BOOL)uploaded atURL:(NSURL *)url error:(NSError * __au
return success;
}

- (BOOL)removeUploadedFiles:(NSArray *)fileURLs withError:(NSError * __autoreleasing *)error {
- (BOOL)removeUploadedFiles:(NSArray<NSURL *> *)fileURLs withError:(NSError * __autoreleasing *)error {
__block BOOL success = NO;
dispatch_sync(_queue, ^{
success = [self queue_removeUploadedFiles:fileURLs withError:error];
Expand Down Expand Up @@ -942,7 +948,7 @@ - (BOOL)queue_markFileUploaded:(BOOL)uploaded atURL:(NSURL *)url error:(NSError
return success;
}

- (BOOL)queue_removeUploadedFiles:(NSArray *)fileURLs withError:(NSError * __autoreleasing *)error {
- (BOOL)queue_removeUploadedFiles:(NSArray<NSURL *> *)fileURLs withError:(NSError * __autoreleasing *)error {
NSFileManager *fileManager = [NSFileManager defaultManager];
__block NSMutableArray *errors = [NSMutableArray array];
BOOL success = [self queue_enumerateLogs:^(NSURL *logFileUrl, BOOL *stop) {
Expand Down Expand Up @@ -1036,6 +1042,12 @@ @interface ORKDataLoggerManager () <ORKDataLoggerExtendedDelegate> {

@implementation ORKDataLoggerManager


- (instancetype)init {
ORKThrowMethodUnavailableException();
return nil;
}

- (instancetype)initWithDirectory:(NSURL *)directory delegate:(id<ORKDataLoggerManagerDelegate>)delegate {
self = [super init];
if (self) {
Expand Down Expand Up @@ -1151,8 +1163,8 @@ - (ORKDataLogger *)dataLoggerForLogName:(NSString *)logName {
return dataLogger;
}

- (NSArray *)logNames {
__block NSArray *logNames = nil;
- (NSArray<NSString *> *)logNames {
__block NSArray<NSString *> *logNames = nil;
dispatch_sync(_queue, ^{
logNames = [_records allKeys];
});
Expand Down Expand Up @@ -1210,7 +1222,7 @@ - (BOOL)enumerateLogsNeedingUpload:(void (^)(ORKDataLogger *dataLogger, NSURL *l
return success;
}

- (BOOL)queue_removeUploadedFiles:(NSArray *)fileURLs error:(NSError * __autoreleasing *)error {
- (BOOL)queue_removeUploadedFiles:(NSArray<NSURL *> *)fileURLs error:(NSError * __autoreleasing *)error {
BOOL success = YES;
NSMutableArray *notRemoved = [NSMutableArray array];
for (NSURL *url in fileURLs) {
Expand All @@ -1233,7 +1245,7 @@ - (BOOL)queue_removeUploadedFiles:(NSArray *)fileURLs error:(NSError * __autorel
return success;
}

- (BOOL)removeUploadedFiles:(NSArray *)fileURLs error:(NSError * __autoreleasing *)error {
- (BOOL)removeUploadedFiles:(NSArray<NSURL *> *)fileURLs error:(NSError * __autoreleasing *)error {

__block BOOL success = YES;
dispatch_sync(_queue, ^{
Expand All @@ -1242,9 +1254,9 @@ - (BOOL)removeUploadedFiles:(NSArray *)fileURLs error:(NSError * __autoreleasing
return success;
}

- (BOOL)queue_unmarkUploadedFiles:(NSArray *)fileURLs error:(NSError * __autoreleasing *)error {
- (BOOL)queue_unmarkUploadedFiles:(NSArray<NSURL *> *)fileURLs error:(NSError * __autoreleasing *)error {
BOOL success = YES;
NSMutableArray *notRemoved = [NSMutableArray array];
NSMutableArray<NSURL *> *notRemoved = [NSMutableArray array];
for (NSURL *url in fileURLs) {
NSString *logName = [url ork_logNameInDirectory:_directory];
ORKDataLogger *logger = _records[logName];
Expand All @@ -1265,7 +1277,7 @@ - (BOOL)queue_unmarkUploadedFiles:(NSArray *)fileURLs error:(NSError * __autorel
return success;
}

- (BOOL)unmarkUploadedFiles:(NSArray *)fileURLs error:(NSError *__autoreleasing *)error {
- (BOOL)unmarkUploadedFiles:(NSArray<NSURL *> *)fileURLs error:(NSError *__autoreleasing *)error {
__block BOOL success = YES;
dispatch_sync(_queue, ^{
success = [self queue_unmarkUploadedFiles:fileURLs error:error];
Expand Down
7 changes: 7 additions & 0 deletions ResearchKit/ActiveTasks/ORKLocationRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@


#import <ResearchKit/ORKRecorder.h>
#import <CoreLocation/CoreLocation.h>


NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -58,6 +59,12 @@ ORK_CLASS_AVAILABLE
step:(nullable ORKStep *)step
outputDirectory:(nullable NSURL *)outputDirectory NS_DESIGNATED_INITIALIZER;


/**
The location manager, if any, being used by this recorder.
*/
@property (nonatomic, strong, nullable, readonly) CLLocationManager *locationManager;

@end

NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion ResearchKit/ActiveTasks/ORKLocationRecorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ @interface ORKLocationRecorder () <CLLocationManagerDelegate> {
BOOL _started;
}

@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, strong, nullable) CLLocationManager *locationManager;

@property (nonatomic) NSTimeInterval uptime;

Expand Down
2 changes: 1 addition & 1 deletion ResearchKit/ActiveTasks/ORKRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ORK_CLASS_AVAILABLE
If your recorder requires or would benefit from read access to HealthKit at
runtime during the task, return the appropriate set of `HKSampleType` objects.
*/
- (nullable NSSet *)requestedHealthKitTypesForReading;
- (nullable NSSet<HKObjectType *> *)requestedHealthKitTypesForReading;

@end

Expand Down
10 changes: 6 additions & 4 deletions ResearchKit/ActiveTasks/ORKRecorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

@implementation ORKRecorderConfiguration

- (instancetype)init {
ORKThrowMethodUnavailableException();
}

- (instancetype)initWithIdentifier:(NSString *)identifier {
self = [super init];
if (self) {
if (nil == identifier) {
@throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"identifier cannot be nil." userInfo:nil];
}
ORKThrowInvalidArgumentExceptionIfNil(identifier);
_identifier = [identifier copy];
}
return self;
Expand Down Expand Up @@ -82,7 +84,7 @@ - (ORKRecorder *)recorderForStep:(ORKStep *)step outputDirectory:(NSURL *)output
return nil;
}

- (NSSet *)requestedHealthKitTypesForReading {
- (NSSet<HKObjectType *> *)requestedHealthKitTypesForReading {
return nil;
}
- (ORKPermissionMask)requestedPermissionMask {
Expand Down
2 changes: 2 additions & 0 deletions ResearchKit/ActiveTasks/ORKSpatialSpanGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
*/
@interface ORKSpatialSpanGame : NSObject

- (instancetype)init NS_UNAVAILABLE;

/**
Returns an initialized spatial span game using the specified game size, sequence length, and seed.
Expand Down
6 changes: 5 additions & 1 deletion ResearchKit/ActiveTasks/ORKSpatialSpanGame.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE


#import "ORKSpatialSpanGame.h"

#import "ORKHelpers.h"

@implementation ORKSpatialSpanGame {
NSInteger *_sequence;
}

- (instancetype)init {
ORKThrowMethodUnavailableException();
}

- (void)generateSequence {
_sequence = calloc(_gameSize, sizeof(NSInteger));
if (_sequence == NULL) {
Expand Down
Loading

0 comments on commit 6ee6c36

Please sign in to comment.