From e1065b047eeade2e17290d9294c41b922827d03f Mon Sep 17 00:00:00 2001 From: Chris Leonavicius Date: Thu, 11 Jul 2019 16:56:31 -0700 Subject: [PATCH] Fix warnings, update podspec to properly support Swift 5 (#55) --- .swift-version | 1 - LayoutTest.podspec | 15 ++++++----- LayoutTest.xcodeproj/project.pbxproj | 8 ++++-- .../xcschemes/LayoutTest.xcscheme | 26 +++++++------------ .../xcschemes/LayoutTestBase.xcscheme | 8 +----- LayoutTest/TestCase/LYTLayoutTestCase.h | 4 +-- LayoutTest/TestCase/LYTLayoutTestCase.m | 6 ++--- LayoutTestBase.podspec | 3 ++- .../Core/Testers/LYTLayoutPropertyTester.h | 4 +-- .../Core/Testers/LYTLayoutPropertyTester.m | 4 +-- .../UIViewHelpers/UIView+LYTTestHelpers.h | 10 +++---- .../UIViewHelpers/UIView+LYTTestHelpers.m | 10 +++---- 12 files changed, 46 insertions(+), 53 deletions(-) delete mode 100644 .swift-version diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 9f55b2c..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -3.0 diff --git a/LayoutTest.podspec b/LayoutTest.podspec index 4fa06d2..1404eaa 100644 --- a/LayoutTest.podspec +++ b/LayoutTest.podspec @@ -1,6 +1,6 @@ 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' @@ -8,6 +8,7 @@ Pod::Spec.new do |spec| 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' @@ -15,18 +16,18 @@ Pod::Spec.new do |spec| 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 diff --git a/LayoutTest.xcodeproj/project.pbxproj b/LayoutTest.xcodeproj/project.pbxproj index f6ef0ab..0befc61 100644 --- a/LayoutTest.xcodeproj/project.pbxproj +++ b/LayoutTest.xcodeproj/project.pbxproj @@ -576,7 +576,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 1100; ORGANIZATIONNAME = LinkedIn; TargetAttributes = { 614FE6381C03EE3C00BB9EE6 = { @@ -595,7 +595,7 @@ }; buildConfigurationList = 615296F7187CAEEB00BAF959 /* Build configuration list for PBXProject "LayoutTest" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -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; @@ -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; diff --git a/LayoutTest.xcodeproj/xcshareddata/xcschemes/LayoutTest.xcscheme b/LayoutTest.xcodeproj/xcshareddata/xcschemes/LayoutTest.xcscheme index 1af1d48..69d3fd5 100644 --- a/LayoutTest.xcodeproj/xcshareddata/xcschemes/LayoutTest.xcscheme +++ b/LayoutTest.xcodeproj/xcshareddata/xcschemes/LayoutTest.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -41,23 +49,11 @@ - - - - - - - - - - - - 'Apache License, Version 2.0' } spec.homepage = 'https://linkedin.github.io/LayoutTest-iOS' spec.authors = 'LinkedIn' @@ -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' diff --git a/LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.h b/LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.h index 5ae0635..8253458 100644 --- a/LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.h +++ b/LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.h @@ -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. @@ -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 diff --git a/LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.m b/LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.m index 53578d9..171c553 100644 --- a/LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.m +++ b/LayoutTestBase/Core/Testers/LYTLayoutPropertyTester.m @@ -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"); diff --git a/LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.h b/LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.h index 2953cc0..17dfa96 100644 --- a/LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.h +++ b/LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.h @@ -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 @@ -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 diff --git a/LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.m b/LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.m index bcdad0a..b6f820f 100644 --- a/LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.m +++ b/LayoutTestBase/UIViewHelpers/UIView+LYTTestHelpers.m @@ -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; @@ -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);