Skip to content

Commit

Permalink
Fix warnings, update podspec to properly support Swift 5 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
crleona authored and oliverhu committed Jul 11, 2019
1 parent 3237f4e commit e1065b0
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 53 deletions.
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

15 changes: 8 additions & 7 deletions LayoutTest.podspec
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
Pod::Spec.new do |spec|
spec.name = 'LayoutTest'
spec.version = '5.0.1'
spec.version = '5.0.2'
spec.license = { :type => 'Apache License, Version 2.0' }
spec.homepage = 'https://linkedin.github.io/LayoutTest-iOS'
spec.authors = 'LinkedIn'
spec.summary = 'LayoutTest enables you to write unit tests which test the layout of a view in multiple configurations.'
spec.source = { :git => 'https://github.com/linkedin/LayoutTest-iOS.git', :tag => spec.version }
spec.platform = :ios, '7.0'
spec.default_subspecs = 'TestCase'
spec.swift_version = '5.0'

spec.subspec 'Swift' do |sp|
sp.dependency 'LayoutTest/SwiftSubspec'
end

spec.subspec 'TestCase' do |sp|
sp.source_files = 'LayoutTest/TestCase'
sp.dependency 'LayoutTestBase/Autolayout', '5.0.1'
sp.dependency 'LayoutTestBase/Catalog', '5.0.1'
sp.dependency 'LayoutTestBase/Config', '5.0.1'
sp.dependency 'LayoutTestBase/Core', '5.0.1'
sp.dependency 'LayoutTestBase/UIViewHelpers', '5.0.1'
sp.dependency 'LayoutTestBase/Autolayout', '5.0.2'
sp.dependency 'LayoutTestBase/Catalog', '5.0.2'
sp.dependency 'LayoutTestBase/Config', '5.0.2'
sp.dependency 'LayoutTestBase/Core', '5.0.2'
sp.dependency 'LayoutTestBase/UIViewHelpers', '5.0.2'
sp.framework = 'XCTest'
end

spec.subspec 'SwiftSubspec' do |sp|
sp.source_files = 'LayoutTest/Swift', 'LayoutTest/LayoutTest.h'
sp.dependency 'LayoutTest/TestCase'
sp.dependency 'LayoutTestBase/Swift', '5.0.1'
sp.dependency 'LayoutTestBase/Swift', '5.0.2'
end
end

8 changes: 6 additions & 2 deletions LayoutTest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0920;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = LinkedIn;
TargetAttributes = {
614FE6381C03EE3C00BB9EE6 = {
Expand All @@ -595,7 +595,7 @@
};
buildConfigurationList = 615296F7187CAEEB00BAF959 /* Build configuration list for PBXProject "LayoutTest" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -845,12 +845,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -897,12 +899,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down
26 changes: 10 additions & 16 deletions LayoutTest.xcodeproj/xcshareddata/xcschemes/LayoutTest.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,9 +26,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "614FE6381C03EE3C00BB9EE6"
BuildableName = "LayoutTest.framework"
BlueprintName = "LayoutTest"
ReferencedContainer = "container:LayoutTest.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -41,23 +49,11 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "614FE6381C03EE3C00BB9EE6"
BuildableName = "LayoutTest.framework"
BlueprintName = "LayoutTest"
ReferencedContainer = "container:LayoutTest.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -73,8 +69,6 @@
ReferencedContainer = "container:LayoutTest.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,18 +26,14 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -53,8 +49,6 @@
ReferencedContainer = "container:LayoutTest.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
4 changes: 2 additions & 2 deletions LayoutTest/TestCase/LYTLayoutTestCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
it will be passed back here.
*/
- (void)runLayoutTestsWithViewProvider:(Class)viewProvider
validation:(__attribute__((noescape)) void(^)(id view, NSDictionary *data, id _Nullable context))validation;
validation:(NS_NOESCAPE void(^)(id view, NSDictionary *data, id _Nullable context))validation;

/**
This is the main method that runs your tests. You pass in a class that conforms to LYTViewProvider and it will run multiple combinations
Expand Down Expand Up @@ -97,7 +97,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)runLayoutTestsWithViewProvider:(Class)viewProvider
limitResults:(LYTTesterLimitResults)limitResults
validation:(__attribute__((noescape)) void(^)(id view, NSDictionary *data, id _Nullable context))validation;
validation:(NS_NOESCAPE void(^)(id view, NSDictionary *data, id _Nullable context))validation;

/**
This method recusively adds all of the subviews of a view to viewsAllowingOverlap. It does NOT add the view you pass in. This is useful if a
Expand Down
6 changes: 3 additions & 3 deletions LayoutTest/TestCase/LYTLayoutTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ + (void)tearDown {
}

- (void)runLayoutTestsWithViewProvider:(Class)viewProvider
validation:(void(^)(id, NSDictionary *, id _Nullable))validation {
validation:(NS_NOESCAPE void(^)(id, NSDictionary *, id _Nullable))validation {
[self runLayoutTestsWithViewProvider:viewProvider
limitResults:LYTTesterLimitResultsNone
validation:validation];
}

- (void)runLayoutTestsWithViewProvider:(Class)viewProvider
limitResults:(LYTTesterLimitResults)limitResults
validation:(void(^)(id view, NSDictionary *data, id _Nullable context))validation {
validation:(NS_NOESCAPE void(^)(id view, NSDictionary *data, id _Nullable context))validation {

// It's too early to do this in setUp because they may override this property in setUp. So, let's do it here. It's ok if we call this multiple times per test. We'll just clean up in tearDown.
if (self.interceptsAutolayoutErrors) {
Expand Down Expand Up @@ -263,7 +263,7 @@ + (BOOL)class:(Class)aClass includedInSet:(NSSet *)set {
return NO;
}

+ (UIView *)firstSuperviewWithAccessibilityLabel:(UIView *)view {
+ (nullable UIView *)firstSuperviewWithAccessibilityLabel:(UIView *)view {
if (view.superview == nil) {
return nil;
} else if (view.superview.accessibilityLabel != nil) {
Expand Down
3 changes: 2 additions & 1 deletion LayoutTestBase.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'LayoutTestBase'
spec.version = '5.0.1'
spec.version = '5.0.2'
spec.license = { :type => 'Apache License, Version 2.0' }
spec.homepage = 'https://linkedin.github.io/LayoutTest-iOS'
spec.authors = 'LinkedIn'
Expand All @@ -9,6 +9,7 @@ Pod::Spec.new do |spec|
spec.platform = :ios, '7.0'
spec.frameworks = 'Foundation', 'UIKit'
spec.default_subspecs = 'Core', 'Autolayout', 'Catalog', 'Config', 'UIViewHelpers'
spec.swift_version = '5.0'

spec.subspec 'Swift' do |sp|
sp.source_files = 'LayoutTestBase/Swift/**/*', 'LayoutTestBase/LayoutTestBase.h'
Expand Down
4 changes: 2 additions & 2 deletions LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ NS_SWIFT_NAME(LayoutPropertyTester)
\param validation Block to validate the view given the data. The data here will not contain any LYTDataValues subclasses and both the view and data
will never be nil. Here you should assert on the properties of the view. If you set a context in your viewForData: method, it will be passed back here.
*/
+ (void)runPropertyTestsWithViewProvider:(Class)viewProvider validation:(__attribute__((noescape)) void(^)(id view, NSDictionary *data, _Nullable id context))validation;
+ (void)runPropertyTestsWithViewProvider:(Class)viewProvider validation:(NS_NOESCAPE void(^)(id view, NSDictionary *data, _Nullable id context))validation;

/**
Runs a suite of tests on a given viewProvider. This is the main method to be used for your unit tests.
Expand All @@ -52,7 +52,7 @@ NS_SWIFT_NAME(LayoutPropertyTester)
\param limitResults Use this parameter to run less combinations. This is useful if you're running into performance problems. See LYTTesterLimitResults
docs for more info.
*/
+ (void)runPropertyTestsWithViewProvider:(Class)viewProvider limitResults:(LYTTesterLimitResults)limitResults validation:(__attribute__((noescape)) void(^)(id view, NSDictionary *data, id _Nullable context))validation;
+ (void)runPropertyTestsWithViewProvider:(Class)viewProvider limitResults:(LYTTesterLimitResults)limitResults validation:(NS_NOESCAPE void(^)(id view, NSDictionary *data, id _Nullable context))validation;

@end

Expand Down
4 changes: 2 additions & 2 deletions LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ @implementation LYTLayoutPropertyTester

#pragma mark - Public

+ (void)runPropertyTestsWithViewProvider:(Class)viewProvider validation:(void(^)(id view, NSDictionary *data, id context))validation {
+ (void)runPropertyTestsWithViewProvider:(Class)viewProvider validation:(NS_NOESCAPE void(^)(id view, NSDictionary *data, id context))validation {
[self runPropertyTestsWithViewProvider:viewProvider
limitResults:LYTTesterLimitResultsNone
validation:validation];
}

+ (void)runPropertyTestsWithViewProvider:(Class)viewProvider limitResults:(LYTTesterLimitResults)limitResults validation:(void(^)(id view, NSDictionary *data, id context))validation {
+ (void)runPropertyTestsWithViewProvider:(Class)viewProvider limitResults:(LYTTesterLimitResults)limitResults validation:(NS_NOESCAPE void(^)(id view, NSDictionary *data, id context))validation {
NSAssert([viewProvider conformsToProtocol:@protocol(LYTViewProvider)], @"You must pass in a class which conforms to LYTViewProvider");
NSAssert(validation, @"You must pass in a validation block");

Expand Down
10 changes: 5 additions & 5 deletions LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ NS_ASSUME_NONNULL_BEGIN
on cell.contentView because it sometimes fails for the contentView in it's
superview due to some UIKit weirdness.
*/
- (void)lyt_recursivelyAssertViewWithinSuperViewBounds:(__attribute__((noescape)) void(^)(NSString *error, UIView *view))errorBlock NS_SWIFT_NAME(recursivelyAssertViewWithinSuperViewBounds(_:));
- (void)lyt_recursivelyAssertViewWithinSuperViewBounds:(NS_NOESCAPE void(^)(NSString *error, UIView *view))errorBlock NS_SWIFT_NAME(recursivelyAssertViewWithinSuperViewBounds(_:));

/**
Useful helper for writing tests. Ensures that none of the subviews of this view overlap.
When comparing CGFloats, (x > y) if and only if (x > y + epsilon). This epsilon value is defined in LYTConfig.
*/
- (void)lyt_assertNoSubviewsOverlap:(__attribute__((noescape)) void(^)(NSString *error, UIView *view1, UIView *view2))errorBlock NS_SWIFT_NAME(assertNoSubviewsOverlap(_:));
- (void)lyt_assertNoSubviewsOverlap:(NS_NOESCAPE void(^)(NSString *error, UIView *view1, UIView *view2))errorBlock NS_SWIFT_NAME(assertNoSubviewsOverlap(_:));

/**
Useful helper for writing tests. Ensures that none of the subviews of this view overlap. It calls this recursively on subviews, but does not test all
Expand All @@ -51,19 +51,19 @@ NS_ASSUME_NONNULL_BEGIN
When comparing CGFloats, (x > y) if and only if (x > y + epsilon). This epsilon value is defined in LYTConfig.
*/
- (void)lyt_recursivelyAssertNoSubviewsOverlap:(__attribute__((noescape)) void(^)(NSString *error, UIView *view1, UIView *view2))errorBlock NS_SWIFT_NAME(recursivelyAssertNoSubviewsOverlap(_:));
- (void)lyt_recursivelyAssertNoSubviewsOverlap:(NS_NOESCAPE void(^)(NSString *error, UIView *view1, UIView *view2))errorBlock NS_SWIFT_NAME(recursivelyAssertNoSubviewsOverlap(_:));

/**
This method first returns the current view, then traverses the view hierarchy.
*/
- (void)lyt_recursivelyTraverseViewHierarchy:(__attribute__((noescape)) void(^)(UIView *subview))subviewBlock NS_SWIFT_NAME(recursivelyTraverseViewHierarchy(_:));
- (void)lyt_recursivelyTraverseViewHierarchy:(NS_NOESCAPE void(^)(UIView *subview))subviewBlock NS_SWIFT_NAME(recursivelyTraverseViewHierarchy(_:));

/**
This method first returns the current view, then traverses the view hierarchy.
It also provides a stop parameter. If you set this to true, then the method will stop recursing on this branch only.
*/
- (void)lyt_recursivelyTraverseViewHierarchyWithStop:(__attribute__((noescape)) void(^)(UIView *subview, BOOL *stopBranch))subviewBlock NS_SWIFT_NAME(recursivelyTraverseViewHierarchyWithStop(_:));
- (void)lyt_recursivelyTraverseViewHierarchyWithStop:(NS_NOESCAPE void(^)(UIView *subview, BOOL *stopBranch))subviewBlock NS_SWIFT_NAME(recursivelyTraverseViewHierarchyWithStop(_:));

@end

Expand Down
10 changes: 5 additions & 5 deletions LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ - (void)lyt_assertViewWithinSuperViewBounds:(void(^)(NSString *error, UIView *vi
}
}

- (void)lyt_assertNoSubviewsOverlap:(void(^)(NSString *error, UIView *view1, UIView *view2))errorBlock {
- (void)lyt_assertNoSubviewsOverlap:(NS_NOESCAPE void(^)(NSString *error, UIView *view1, UIView *view2))errorBlock {
NSInteger subviewsCount = [self.subviews count];

CGFloat epsilon = [LYTConfig sharedInstance].cgFloatEpsilon;
Expand Down Expand Up @@ -77,25 +77,25 @@ - (void)lyt_assertNoSubviewsOverlap:(void(^)(NSString *error, UIView *view1, UIV
}
}

- (void)lyt_recursivelyAssertViewWithinSuperViewBounds:(void(^)(NSString *error, UIView *view))errorBlock {
- (void)lyt_recursivelyAssertViewWithinSuperViewBounds:(NS_NOESCAPE void(^)(NSString *error, UIView *view))errorBlock {
[self lyt_recursivelyTraverseViewHierarchy:^(UIView *subview) {
[subview lyt_assertViewWithinSuperViewBounds:errorBlock];
}];
}

- (void)lyt_recursivelyAssertNoSubviewsOverlap:(void(^)(NSString *error, UIView *view1, UIView *view2))errorBlock {
- (void)lyt_recursivelyAssertNoSubviewsOverlap:(NS_NOESCAPE void(^)(NSString *error, UIView *view1, UIView *view2))errorBlock {
[self lyt_recursivelyTraverseViewHierarchy:^(UIView *subview) {
[subview lyt_assertNoSubviewsOverlap:errorBlock];
}];
}

- (void)lyt_recursivelyTraverseViewHierarchy:(void(^)(UIView *))subviewBlock {
- (void)lyt_recursivelyTraverseViewHierarchy:(NS_NOESCAPE void(^)(UIView *))subviewBlock {
[self lyt_recursivelyTraverseViewHierarchyWithStop:^(UIView *subview, BOOL *stopBranch) {
subviewBlock(subview);
}];
}

- (void)lyt_recursivelyTraverseViewHierarchyWithStop:(void(^)(UIView *subview, BOOL *stopBranch))subviewBlock {
- (void)lyt_recursivelyTraverseViewHierarchyWithStop:(NS_NOESCAPE void(^)(UIView *subview, BOOL *stopBranch))subviewBlock {
BOOL stopRecursing = NO;
subviewBlock(self, &stopRecursing);

Expand Down

0 comments on commit e1065b0

Please sign in to comment.