Skip to content

Commit

Permalink
Compile Tests & Improve Availability (#16)
Browse files Browse the repository at this point in the history
# Compile Tests & Improve Availability

## ⚙️ Release Notes 
- Compiles Tests & Improves Availability of RK for visionOS


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
PSchmiedmayer authored Feb 6, 2024
1 parent 1b73fca commit 0836d63
Show file tree
Hide file tree
Showing 34 changed files with 92 additions and 65 deletions.
14 changes: 8 additions & 6 deletions ResearchKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5538,7 +5538,7 @@
050968E6236B71FF006F734C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
PRODUCT_NAME = "";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
Expand All @@ -5551,7 +5551,7 @@
3FFF186A1829DB1E00167070 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
PRODUCT_NAME = "";
SKIP_INSTALL = YES;
SWIFT_OBJC_INTEROP_MODE = objc;
Expand All @@ -5572,7 +5572,6 @@
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = ResearchKitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -5581,9 +5580,11 @@
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "org.researchkit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_OBJC_BRIDGING_HEADER = "ResearchKitTests/ResearchKitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = 1;
TARGETED_DEVICE_FAMILY = "1,7";
};
name = Debug;
};
Expand All @@ -5596,7 +5597,6 @@
COPY_PHASE_STRIP = NO;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = ResearchKitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -5606,9 +5606,11 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.researchkit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SWIFT_OBJC_BRIDGING_HEADER = "ResearchKitTests/ResearchKitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = 1;
TARGETED_DEVICE_FAMILY = "1,7";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
2 changes: 0 additions & 2 deletions ResearchKit/ActiveTasks/ORKSecondaryTaskStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

#import <ResearchKit/ResearchKit.h>

Expand All @@ -46,4 +45,3 @@ ORK_CLASS_AVAILABLE

NS_ASSUME_NONNULL_END

#endif
4 changes: 0 additions & 4 deletions ResearchKit/ActiveTasks/ORKSecondaryTaskStep.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

#import "ORKSecondaryTaskStep.h"
#import "ORKSecondaryTaskStepViewController.h"
#import "ORKHelpers_Internal.h"
Expand Down Expand Up @@ -99,5 +97,3 @@ - (NSUInteger)hash {
}

@end

#endif
4 changes: 0 additions & 4 deletions ResearchKit/ActiveTasks/ORKSecondaryTaskStepViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

#import <ResearchKit/ResearchKit.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -40,5 +38,3 @@ ORK_CLASS_AVAILABLE
@end

NS_ASSUME_NONNULL_END

#endif
4 changes: 0 additions & 4 deletions ResearchKit/ActiveTasks/ORKSecondaryTaskStepViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

#import "ORKSecondaryTaskStepViewController.h"
#import "ORKSecondaryTaskStep.h"
#import "ORKStepViewController_Internal.h"
Expand Down Expand Up @@ -124,5 +122,3 @@ - (void)taskViewController:(ORKTaskViewController *)taskViewController didFinish
}

@end

#endif
9 changes: 3 additions & 6 deletions ResearchKit/Common/ORKHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,10 @@ id ORKFindInArrayByKey(NSArray *array, NSString *key, id value) {
}

CGFloat ScreenScale() {
#if TARGET_OS_IOS
return ScreenScale();
#else
// Assuming VisionOS or any other non-iOS platform
// Choose a "best possible value" for VisionOS here. For instance, 2.0 could be a sensible default
// representing @2x retina display, which is quite common.
#if TARGET_OS_VISION
return 2.0;
#else
return [UIScreen mainScreen].scale;
#endif
}

Expand Down
4 changes: 0 additions & 4 deletions ResearchKit/Common/ORKOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS


#import <Foundation/Foundation.h>

Expand Down Expand Up @@ -72,5 +70,3 @@ typedef void (^ORKOperationBlock)(ORKOperation *operation);
- (void)doTimeout;

@end

#endif
4 changes: 0 additions & 4 deletions ResearchKit/Common/ORKOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

#import "ORKOperation.h"
#import "ORKErrors.h"
#import "ORKHelpers_Internal.h"
Expand Down Expand Up @@ -171,5 +169,3 @@ - (void)doTimeout {
}

@end

#endif
2 changes: 2 additions & 0 deletions ResearchKit/Common/ORKPageStepViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,14 @@ - (BOOL)stepViewControllerHasPreviousStep:(ORKStepViewController *)stepViewContr
return [self hasPreviousStep] || ([self stepInDirection:ORKPageNavigationDirectionReverse] != nil);
}

#if TARGET_OS_IOS
- (void)stepViewController:(ORKStepViewController *)stepViewController recorder:(ORKRecorder *)recorder didFailWithError:(NSError *)error {
ORKStrongTypeOf(self.delegate) delegate = self.delegate;
if ([delegate respondsToSelector:@selector(stepViewController:recorder:didFailWithError:)]) {
[delegate stepViewController:self recorder:recorder didFailWithError:error];
}
}
#endif

#pragma mark Navigation

Expand Down
2 changes: 2 additions & 0 deletions ResearchKit/Common/ORKStepViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ typedef NS_ENUM(NSInteger, ORKStepViewControllerNavigationDirection) {
*/
- (void)stepViewControllerDidFail:(ORKStepViewController *)stepViewController withError:(nullable NSError *)error;

#if TARGET_OS_IOS
/**
Tells the delegate when a recorder error has been detected during the step.
Expand All @@ -119,6 +120,7 @@ typedef NS_ENUM(NSInteger, ORKStepViewControllerNavigationDirection) {
@param error The error detected.
*/
- (void)stepViewController:(ORKStepViewController *)stepViewController recorder:(ORKRecorder *)recorder didFailWithError:(NSError *)error;
#endif

@optional
/**
Expand Down
4 changes: 0 additions & 4 deletions ResearchKit/Common/ORKSurveyAnswerCellForPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ - (void)setupConstraintsForView:(UIView *)view {
[[view.topAnchor constraintEqualToAnchor:self.topAnchor] setActive:YES];

if (_dontKnowButton) {
#if TARGET_OS_IOS
CGFloat separatorHeight = 1.0 / ScreenScale();
#else
CGFloat separatorHeight = 1.0;
#endif
[[_dividerView.topAnchor constraintEqualToAnchor:view.bottomAnchor constant:DividerViewTopPadding] setActive:YES];
[[_dividerView.leftAnchor constraintEqualToAnchor:self.leftAnchor] setActive:YES];
[[_dividerView.rightAnchor constraintEqualToAnchor:self.rightAnchor] setActive:YES];
Expand Down
8 changes: 0 additions & 8 deletions ResearchKit/Common/ORKTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ - (void)setShowBottomSeparator:(BOOL)showBottomSeparator {
[self addSubview:_bottomSeparator];
_bottomSeparator.translatesAutoresizingMaskIntoConstraints = NO;

#if TARGET_OS_IOS
CGFloat separatorHeight = 1.0 / ScreenScale();
#else
CGFloat separatorHeight = 1.0;
#endif

NSMutableArray *constraints = [NSMutableArray array];
[constraints addObject:[NSLayoutConstraint constraintWithItem:_bottomSeparator
Expand Down Expand Up @@ -132,11 +128,7 @@ - (void)setShowTopSeparator:(BOOL)showTopSeparator {
[self addSubview:_topSeparator];
_topSeparator.translatesAutoresizingMaskIntoConstraints = NO;

#if TARGET_OS_IOS
CGFloat separatorHeight = 1.0 / ScreenScale();
#else
CGFloat separatorHeight = 1.0;
#endif

NSMutableArray *constraints = [NSMutableArray array];
[constraints addObject:[NSLayoutConstraint constraintWithItem:_topSeparator
Expand Down
12 changes: 2 additions & 10 deletions ResearchKit/Common/ORKTaskReviewViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ - (void)setupLabels {
}

- (void)setupConstraints {
#if TARGET_OS_IOS
CGFloat screenScale = self.window.screen.scale; // Use screen.scale; self.contentScaleFactor remains 1.0 until later
#else
CGFloat screenScale = 1.0;
#endif
CGFloat screenScale = ScreenScale(); // Use screen.scale; self.contentScaleFactor remains 1.0 until later

[[_containerView.topAnchor constraintEqualToAnchor:self.contentView.topAnchor constant:1.0 / screenScale] setActive:YES];
[[_containerView.leftAnchor constraintEqualToAnchor:self.contentView.leftAnchor constant:ORKCardLeftRightMarginForWindow(self.window)] setActive:YES];
Expand Down Expand Up @@ -325,11 +321,7 @@ - (void)setupConstraints {
[[_button.leadingAnchor constraintEqualToAnchor:_containerView.leadingAnchor constant:EditAnswerButtonLeftPadding] setActive:YES];
[[_containerView.bottomAnchor constraintEqualToAnchor:_button.bottomAnchor constant:EditAnswerButtonTopBottomPadding] setActive:YES];

#if TARGET_OS_IOS
CGFloat screenScale = self.window.screen.scale; // Use screen.scale; self.contentScaleFactor remains 1.0 until later
#else
CGFloat screenScale = 1.0;
#endif
CGFloat screenScale = ScreenScale();

[_separator.heightAnchor constraintEqualToConstant:1.0 / screenScale].active = YES;
[_separator.leadingAnchor constraintEqualToAnchor:_containerView.leadingAnchor].active = YES;
Expand Down
6 changes: 1 addition & 5 deletions ResearchKit/Common/ORKTintedImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ - (UIImage *)imageByTintingImage:(UIImage *)image {
}

UIColor *tintColor = self.tintColor;
#if TARGET_OS_IOS
CGFloat screenScale = self.window.screen.scale; // Use screen.scale; self.contentScaleFactor remains 1.0 until later
#else
CGFloat screenScale = 1.0;
#endif
CGFloat screenScale = ScreenScale();
if (screenScale > 0 && (![_appliedTintColor isEqual:tintColor] || !ORKCGFloatNearlyEqualToFloat(_appliedScaleFactor, screenScale))) {
_appliedTintColor = tintColor;
_appliedScaleFactor = screenScale;
Expand Down
4 changes: 4 additions & 0 deletions ResearchKitTests/ORKActiveStepTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

import XCTest
@testable import ResearchKit

Expand Down Expand Up @@ -115,3 +117,5 @@ class ORKActiveStepTests: XCTestCase {

}
}

#endif
4 changes: 4 additions & 0 deletions ResearchKitTests/ORKActiveTaskResultTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

import XCTest
@testable import ResearchKit

Expand Down Expand Up @@ -676,3 +678,5 @@ class ORKTrailmakingResultTests: XCTestCase {
XCTAssert(result.isEqual(newResult))
}
}

#endif
4 changes: 4 additions & 0 deletions ResearchKitTests/ORKAudioStepViewControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

#import <Foundation/Foundation.h>
#import <ResearchKit/ORKAudioFitnessStepViewController.h>

Expand Down Expand Up @@ -122,3 +124,5 @@ - (void)testFinishingTheTaskStopsAudio {
}

@end

#endif
4 changes: 4 additions & 0 deletions ResearchKitTests/ORKAudiometryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

#import <XCTest/XCTest.h>

@import ResearchKit.Private;
Expand Down Expand Up @@ -102,3 +104,5 @@ - (void)runTestForAudiogram:(NSDictionary *)audiogramDict onAudiometryEngine:(id
}

@end

#endif
4 changes: 4 additions & 0 deletions ResearchKitTests/ORKConsentDocumentTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*/


#if TARGET_OS_IOS

@import XCTest;
@import ResearchKit.Private;

Expand Down Expand Up @@ -192,3 +194,5 @@ - (void)testMakePDFWithCompletionHandler_whenWriterReturnsError_callsCompletionB
}

@end

#endif
3 changes: 3 additions & 0 deletions ResearchKitTests/ORKConsentSectionFormatterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

@import XCTest;
@import ResearchKit.Private;
Expand Down Expand Up @@ -80,3 +81,5 @@ - (void)testHTMLForSection_whenSectionHasNoHTMLContent_formatsEscapedContent {
}

@end

#endif
3 changes: 3 additions & 0 deletions ResearchKitTests/ORKConsentSignatureFormatterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if TARGET_OS_IOS

@import XCTest;
@import ResearchKit.Private;
Expand Down Expand Up @@ -183,3 +184,5 @@ - (void)testHTMLForSignature_withNameAndImage_formatsSignature {
}

@end

#endif
4 changes: 4 additions & 0 deletions ResearchKitTests/ORKConsentTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*/


#if TARGET_OS_IOS

@import XCTest;
@import ResearchKit.Private;

Expand All @@ -52,3 +54,5 @@ - (void)testContentEscaping {
}

@end

#endif
Loading

0 comments on commit 0836d63

Please sign in to comment.