From 2da74875b08f498965ee17edd91af6835c18851d Mon Sep 17 00:00:00 2001 From: Alexandre Podlewski Date: Fri, 20 Oct 2023 12:00:22 +0200 Subject: [PATCH 1/5] Raise minimal iOS and tvOS version support to 14.0 --- ADUtils.podspec | 4 ++-- ADUtils.xcodeproj/project.pbxproj | 8 ++++---- CHANGELOG.md | 3 ++- Podfile | 2 +- Podfile.lock | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ADUtils.podspec b/ADUtils.podspec index 0f12dc4..b0a5d93 100644 --- a/ADUtils.podspec +++ b/ADUtils.podspec @@ -4,8 +4,8 @@ Pod::Spec.new do |spec| spec.authors = 'Fabernovel' spec.homepage = 'https://github.com/faberNovel/ADUtils' spec.summary = 'Fabernovel\'s toolbox for iOS' - spec.ios.deployment_target = '13.0' - spec.tvos.deployment_target = '13.0' + spec.ios.deployment_target = '14.0' + spec.tvos.deployment_target = '14.0' spec.license = { :type => 'MIT', :text => 'Created and licensed by Fabernovel Technologies. Copyright 2014-2018 Fabernovel Technologies. All rights reserved.' } spec.source = { :git => 'https://github.com/faberNovel/ADUtils.git', :tag => "v#{spec.version}" } spec.framework = 'Foundation', 'UIKit' diff --git a/ADUtils.xcodeproj/project.pbxproj b/ADUtils.xcodeproj/project.pbxproj index 732706c..9a5284a 100644 --- a/ADUtils.xcodeproj/project.pbxproj +++ b/ADUtils.xcodeproj/project.pbxproj @@ -921,7 +921,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; PROVISIONING_PROFILE_SPECIFIER = "$(PROFILE_UDID)"; SDKROOT = iphoneos; SWIFT_STRICT_CONCURRENCY = complete; @@ -998,7 +998,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PROVISIONING_PROFILE_SPECIFIER = "$(PROFILE_UDID)"; SDKROOT = iphoneos; @@ -1079,7 +1079,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; PROVISIONING_PROFILE_SPECIFIER = "$(PROFILE_UDID)"; SDKROOT = iphoneos; SWIFT_STRICT_CONCURRENCY = complete; @@ -1159,7 +1159,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; PROVISIONING_PROFILE_SPECIFIER = "$(PROFILE_UDID)"; SDKROOT = iphoneos; SWIFT_STRICT_CONCURRENCY = complete; diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a227fb..fcc2e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ All notable changes to this project will be documented in this file. - Add Swift Concurrency support ### Removed -- Drop support for iOS 11 and iOS 12 +- Drop support for iOS 11, 12 and 13 +- Drop support for tvOS 11, 12 and 13 - Drop support for Swift below 5.7 ## [11.5.0] - 2023-09-19 diff --git a/Podfile b/Podfile index 09f2363..289b89d 100644 --- a/Podfile +++ b/Podfile @@ -1,4 +1,4 @@ -platform :ios, '13.0' +platform :ios, '14.0' use_frameworks! target 'ADUtilsApp' do diff --git a/Podfile.lock b/Podfile.lock index 97c81f4..2a5acf9 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -30,12 +30,12 @@ EXTERNAL SOURCES: :path: "./" SPEC CHECKSUMS: - ADUtils: 12fd5ba501a61bddfbf8ae68b335b1cfdbece393 + ADUtils: 393dbb0c1fd8c458367eb487f348862d37a5c983 Nimble: b279b3ca9e094508778aab5c76417be158d3ad04 OCMock: 9491e4bec59e0b267d52a9184ff5605995e74be8 Quick: efab97aca76d60be86c15daa533b2cdfbe1a74d3 SwiftLint: 4fa9579c63416865179bc416f0a92d55f009600d -PODFILE CHECKSUM: 6914b9ce5e1410eb72fa1a28f44d2a94b4424fca +PODFILE CHECKSUM: a87d7020e3dc0edf7a63dd3f642255f1bc8dcd8f COCOAPODS: 1.13.0 From 7ac1f05e422f4aa728f6b118f5a833c6558785b6 Mon Sep 17 00:00:00 2001 From: Alexandre Podlewski Date: Fri, 20 Oct 2023 12:23:03 +0200 Subject: [PATCH 2/5] Remove no longer needed @available and #available --- ADUtilsTests/ADLayoutGuideTestsObjc.m | 144 ++++++----- ADUtilsTests/ADViewLayoutGuideTestsObjc.m | 166 +++++++------ ADUtilsTests/ADViewLayoutTestsObjc.m | 176 +++++++------- ADUtilsTests/DynamicFontTest.swift | 1 - .../LayoutGuideConstraintsTests.swift | 2 - .../NSDirectionalEdgeInsetsTests.swift | 2 - .../Security/SecureArchiverTests.swift | 1 - .../ViewInsertionWithMarginTest.swift | 2 - Modules/ADUtils/DynamicFont.swift | 227 +----------------- Modules/ADUtils/FontDescription.swift | 2 - .../NSDirectionalEdgeInsets+Utilities.swift | 2 - Modules/ADUtils/UIImage+Color.swift | 39 ++- .../ADUtils/UILayoutGuide+Constraints.swift | 2 - .../ADUtils/UINavigationItem+BackItem.swift | 8 +- Modules/ADUtils/UIView+Constraints.swift | 2 - .../UIView+LayoutGuideConstraints.swift | 17 -- .../UIViewController+ChildInsertion.swift | 2 - Modules/ADUtils_security/SecureArchiver.swift | 1 - 18 files changed, 263 insertions(+), 533 deletions(-) diff --git a/ADUtilsTests/ADLayoutGuideTestsObjc.m b/ADUtilsTests/ADLayoutGuideTestsObjc.m index 02f97b4..8de6a7b 100644 --- a/ADUtilsTests/ADLayoutGuideTestsObjc.m +++ b/ADUtilsTests/ADLayoutGuideTestsObjc.m @@ -118,79 +118,77 @@ - (void)spec { }); }); - if (@available(iOS 13.0, *)) { - describe(@"Should not translate autoresizing mask into constaints", ^{ - - __block UIView * view; - __block UILayoutGuide * layoutGuide; - - beforeEach(^{ - view = [UIView new]; - layoutGuide = [UILayoutGuide new]; - [view addLayoutGuide:layoutGuide]; - }); - - // Pin to superview - - it(@"Pin to superview", ^{ - [layoutGuide ad_pinToOwningViewUsingDirectionalEdges:YES]; - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview edges", ^{ - [layoutGuide ad_pinToOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll]; - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview insets", ^{ - [layoutGuide ad_pinToOwningViewWithDirectionalInsets:NSDirectionalEdgeInsetsZero]; - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview edges insets", ^{ - [layoutGuide ad_pinToOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero]; - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview edges insets priority", ^{ - [layoutGuide ad_pinToOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero - priority:UILayoutPriorityRequired]; - expect(view.constraints.count).to(equal(4)); - }); - - // Constrain in superview - - it(@"Constrain in superview", ^{ - [layoutGuide ad_constrainInOwningViewUsingDirectionalEdges:YES]; - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Constrain in superview edges", ^{ - [layoutGuide ad_constrainInOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll]; - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Constrain in superview insets", ^{ - [layoutGuide ad_constrainInOwningViewWithDirectionalInsets:NSDirectionalEdgeInsetsZero]; - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Constrain in superview edges insets", ^{ - [layoutGuide ad_constrainInOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero]; - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Constrain in superview edges insets priority", ^{ - [layoutGuide ad_constrainInOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero - priority:UILayoutPriorityRequired]; - expect(view.constraints.count).to(equal(4)); - }); - }); - } + describe(@"Should not translate autoresizing mask into constaints", ^{ + + __block UIView * view; + __block UILayoutGuide * layoutGuide; + + beforeEach(^{ + view = [UIView new]; + layoutGuide = [UILayoutGuide new]; + [view addLayoutGuide:layoutGuide]; + }); + + // Pin to superview + + it(@"Pin to superview", ^{ + [layoutGuide ad_pinToOwningViewUsingDirectionalEdges:YES]; + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview edges", ^{ + [layoutGuide ad_pinToOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll]; + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview insets", ^{ + [layoutGuide ad_pinToOwningViewWithDirectionalInsets:NSDirectionalEdgeInsetsZero]; + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview edges insets", ^{ + [layoutGuide ad_pinToOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero]; + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview edges insets priority", ^{ + [layoutGuide ad_pinToOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero + priority:UILayoutPriorityRequired]; + expect(view.constraints.count).to(equal(4)); + }); + + // Constrain in superview + + it(@"Constrain in superview", ^{ + [layoutGuide ad_constrainInOwningViewUsingDirectionalEdges:YES]; + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Constrain in superview edges", ^{ + [layoutGuide ad_constrainInOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll]; + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Constrain in superview insets", ^{ + [layoutGuide ad_constrainInOwningViewWithDirectionalInsets:NSDirectionalEdgeInsetsZero]; + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Constrain in superview edges insets", ^{ + [layoutGuide ad_constrainInOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero]; + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Constrain in superview edges insets priority", ^{ + [layoutGuide ad_constrainInOwningViewWithDirectionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero + priority:UILayoutPriorityRequired]; + expect(view.constraints.count).to(equal(4)); + }); + }); } @end diff --git a/ADUtilsTests/ADViewLayoutGuideTestsObjc.m b/ADUtilsTests/ADViewLayoutGuideTestsObjc.m index ee58651..b8327e9 100644 --- a/ADUtilsTests/ADViewLayoutGuideTestsObjc.m +++ b/ADUtilsTests/ADViewLayoutGuideTestsObjc.m @@ -112,90 +112,88 @@ - (void)spec { }); }); - if (@available(iOS 13.0, *)) { - describe(@"Should not translate autoresizing mask into constaints using directional edges and insets", ^{ - - __block UIView * view; - __block UIView * subview; - - beforeEach(^{ - view = [UIView new]; - subview = [UIView new]; - [view addSubview:subview]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beTrue()); - }); - - // Pin to layout guide - - it(@"Pin to layout guide", ^{ - [subview ad_pinToLayoutGuide:view.layoutMarginsGuide usingDirectionalEdges:YES]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Pin to layout guide edges", ^{ - [subview ad_pinToLayoutGuide:view.layoutMarginsGuide directionalEdges:NSDirectionalRectEdgeAll]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Pin to layout guide insets", ^{ - [subview ad_pinToLayoutGuide:view.layoutMarginsGuide insets:UIEdgeInsetsZero]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Pin to layout guide edges insets", ^{ - [subview ad_pinToLayoutGuide:view.layoutMarginsGuide - directionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Pin to layout guide edges insets", ^{ - [subview ad_pinToLayoutGuide:view.layoutMarginsGuide - directionalInsets:NSDirectionalEdgeInsetsZero - priority:UILayoutPriorityRequired]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Pin to layout guide edges insets priority", ^{ - [subview ad_pinToLayoutGuide:view.layoutMarginsGuide - directionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero priority:UILayoutPriorityRequired]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - // Constrain in layout guide - - it(@"Constrain in layout guide", ^{ - [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide usingDirectionalEdges:YES]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Constrain in layout guide edges", ^{ - [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide directionalEdges:NSDirectionalRectEdgeAll]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Constrain in layout guide insets", ^{ - [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide directionalInsets:NSDirectionalEdgeInsetsZero]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Constrain in layout guide edges insets", ^{ - [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide - directionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - - it(@"Constrain in layout guide edges insets priority", ^{ - [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide - directionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero - priority:UILayoutPriorityRequired]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - }); - }); - } + describe(@"Should not translate autoresizing mask into constaints using directional edges and insets", ^{ + + __block UIView * view; + __block UIView * subview; + + beforeEach(^{ + view = [UIView new]; + subview = [UIView new]; + [view addSubview:subview]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beTrue()); + }); + + // Pin to layout guide + + it(@"Pin to layout guide", ^{ + [subview ad_pinToLayoutGuide:view.layoutMarginsGuide usingDirectionalEdges:YES]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Pin to layout guide edges", ^{ + [subview ad_pinToLayoutGuide:view.layoutMarginsGuide directionalEdges:NSDirectionalRectEdgeAll]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Pin to layout guide insets", ^{ + [subview ad_pinToLayoutGuide:view.layoutMarginsGuide insets:UIEdgeInsetsZero]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Pin to layout guide edges insets", ^{ + [subview ad_pinToLayoutGuide:view.layoutMarginsGuide + directionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Pin to layout guide edges insets", ^{ + [subview ad_pinToLayoutGuide:view.layoutMarginsGuide + directionalInsets:NSDirectionalEdgeInsetsZero + priority:UILayoutPriorityRequired]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Pin to layout guide edges insets priority", ^{ + [subview ad_pinToLayoutGuide:view.layoutMarginsGuide + directionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero priority:UILayoutPriorityRequired]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + // Constrain in layout guide + + it(@"Constrain in layout guide", ^{ + [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide usingDirectionalEdges:YES]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Constrain in layout guide edges", ^{ + [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide directionalEdges:NSDirectionalRectEdgeAll]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Constrain in layout guide insets", ^{ + [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide directionalInsets:NSDirectionalEdgeInsetsZero]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Constrain in layout guide edges insets", ^{ + [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide + directionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + + it(@"Constrain in layout guide edges insets priority", ^{ + [subview ad_constrainInLayoutGuide:view.layoutMarginsGuide + directionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero + priority:UILayoutPriorityRequired]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + }); + }); } @end diff --git a/ADUtilsTests/ADViewLayoutTestsObjc.m b/ADUtilsTests/ADViewLayoutTestsObjc.m index 6b31427..015bf7f 100644 --- a/ADUtilsTests/ADViewLayoutTestsObjc.m +++ b/ADUtilsTests/ADViewLayoutTestsObjc.m @@ -141,95 +141,93 @@ - (void)spec { }); }); - if (@available(iOS 13.0, *)) { - describe(@"Should not translate autoresizing mask into constaints using directional edges and insets", ^{ - - __block UIView * view; - __block UIView * subview; - - beforeEach(^{ - view = [UIView new]; - subview = [UIView new]; - [view addSubview:subview]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beTrue()); - }); - - // Pin to superview - - it(@"Pin to superview", ^{ - [subview ad_pinToSuperviewUsingDirectionalEdges:YES]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview edges", ^{ - [subview ad_pinToSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview insets", ^{ - [subview ad_pinToSuperviewWithDirectionalInsets:NSDirectionalEdgeInsetsZero]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview edges insets", ^{ - [subview ad_pinToSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll insets:NSDirectionalEdgeInsetsZero]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview edges priority", ^{ - [subview ad_pinToSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll priority: UILayoutPriorityRequired]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Pin to superview edges insets priority", ^{ - [subview ad_pinToSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero - priority:UILayoutPriorityRequired]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - // Constrain in superview - - it(@"Constrain in superview", ^{ - [subview ad_constrainInSuperviewUsingDirectionalEdges:YES]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Constrain in superview edges", ^{ - [subview ad_constrainInSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Constrain in superview insets", ^{ - [subview ad_constrainInSuperviewWithDirectionalInsets:NSDirectionalEdgeInsetsZero]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Constrain in superview edges insets", ^{ - [subview ad_constrainInSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - - it(@"Constrain in superview edges insets priority", ^{ - [subview ad_constrainInSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll - insets:NSDirectionalEdgeInsetsZero - priority:UILayoutPriorityRequired]; - expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); - expect(view.constraints.count).to(equal(4)); - }); - }); - } + describe(@"Should not translate autoresizing mask into constaints using directional edges and insets", ^{ + + __block UIView * view; + __block UIView * subview; + + beforeEach(^{ + view = [UIView new]; + subview = [UIView new]; + [view addSubview:subview]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beTrue()); + }); + + // Pin to superview + + it(@"Pin to superview", ^{ + [subview ad_pinToSuperviewUsingDirectionalEdges:YES]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview edges", ^{ + [subview ad_pinToSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview insets", ^{ + [subview ad_pinToSuperviewWithDirectionalInsets:NSDirectionalEdgeInsetsZero]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview edges insets", ^{ + [subview ad_pinToSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll insets:NSDirectionalEdgeInsetsZero]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview edges priority", ^{ + [subview ad_pinToSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll priority: UILayoutPriorityRequired]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Pin to superview edges insets priority", ^{ + [subview ad_pinToSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero + priority:UILayoutPriorityRequired]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + // Constrain in superview + + it(@"Constrain in superview", ^{ + [subview ad_constrainInSuperviewUsingDirectionalEdges:YES]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Constrain in superview edges", ^{ + [subview ad_constrainInSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Constrain in superview insets", ^{ + [subview ad_constrainInSuperviewWithDirectionalInsets:NSDirectionalEdgeInsetsZero]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Constrain in superview edges insets", ^{ + [subview ad_constrainInSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + + it(@"Constrain in superview edges insets priority", ^{ + [subview ad_constrainInSuperviewWithDirectionalEdges:NSDirectionalRectEdgeAll + insets:NSDirectionalEdgeInsetsZero + priority:UILayoutPriorityRequired]; + expect(subview.translatesAutoresizingMaskIntoConstraints).to(beFalse()); + expect(view.constraints.count).to(equal(4)); + }); + }); } @end diff --git a/ADUtilsTests/DynamicFontTest.swift b/ADUtilsTests/DynamicFontTest.swift index cb946e2..1c4de86 100644 --- a/ADUtilsTests/DynamicFontTest.swift +++ b/ADUtilsTests/DynamicFontTest.swift @@ -92,7 +92,6 @@ class DynamicFontTest: QuickSpec { describe("display SwiftUI fonts") { - @available(iOS 14.0, *) struct DynamicFontsView: View { let types: [Font.TextStyle] = [ diff --git a/ADUtilsTests/LayoutGuideConstraintsTests.swift b/ADUtilsTests/LayoutGuideConstraintsTests.swift index aa17e48..3408cc4 100644 --- a/ADUtilsTests/LayoutGuideConstraintsTests.swift +++ b/ADUtilsTests/LayoutGuideConstraintsTests.swift @@ -346,8 +346,6 @@ class LayoutGuideConstraintsTests: QuickSpec { } } - @available(iOS 13.0, *) - @available(tvOSApplicationExtension 13.0, *) private static func directionalEdgesSpec() { describe("Pin to layout guide using NSDirectionalRectEdge and NSDirectionalRectEdge") { diff --git a/ADUtilsTests/NSDirectionalEdgeInsetsTests.swift b/ADUtilsTests/NSDirectionalEdgeInsetsTests.swift index 3115432..e8f49ac 100644 --- a/ADUtilsTests/NSDirectionalEdgeInsetsTests.swift +++ b/ADUtilsTests/NSDirectionalEdgeInsetsTests.swift @@ -10,8 +10,6 @@ import Quick import Nimble import ADUtils -@available(iOS 13.0, *) -@available(tvOSApplicationExtension 13.0, *) class NSDirectionalEdgeInsetsTests: QuickSpec { override class func spec() { diff --git a/ADUtilsTests/Security/SecureArchiverTests.swift b/ADUtilsTests/Security/SecureArchiverTests.swift index 2144822..b22d60f 100644 --- a/ADUtilsTests/Security/SecureArchiverTests.swift +++ b/ADUtilsTests/Security/SecureArchiverTests.swift @@ -60,7 +60,6 @@ private class KeychainArchiverImplementation: KeychainArchiver { } -@available(iOS 13.0, *) class SecureArchiverTests: QuickSpec { override class func spec() { diff --git a/ADUtilsTests/ViewInsertionWithMarginTest.swift b/ADUtilsTests/ViewInsertionWithMarginTest.swift index 2d44e63..a22510d 100644 --- a/ADUtilsTests/ViewInsertionWithMarginTest.swift +++ b/ADUtilsTests/ViewInsertionWithMarginTest.swift @@ -280,8 +280,6 @@ class ViewInsertionWithMargin: QuickSpec { } } - @available(iOS 13.0, *) - @available(tvOSApplicationExtension 13.0, *) private static func directionalEdgesSpec() { describe("Pin to superview") { diff --git a/Modules/ADUtils/DynamicFont.swift b/Modules/ADUtils/DynamicFont.swift index eb5ddc3..2b3b4d8 100644 --- a/Modules/ADUtils/DynamicFont.swift +++ b/Modules/ADUtils/DynamicFont.swift @@ -24,10 +24,7 @@ public protocol DynamicFontProvider { /** Provides a SwiftUI font for the given textStyle - parameter textStyle: The font text style - - Note: On iOS 13 the font will scale like the body text style. - From iOS 14 it will scale like the provided text style. */ - @available(iOS 13.0, tvOS 13.0, *) func font(forTextStyle textStyle: Font.TextStyle) -> Font } @@ -67,7 +64,6 @@ public struct DynamicFont: DynamicFontProvider { return provider.font(forTextStyle: textStyle) } - @available(iOS 13.0, tvOS 13.0, *) public func font(forTextStyle textStyle: Font.TextStyle) -> Font { return provider.font(forTextStyle: textStyle) } @@ -81,7 +77,6 @@ private struct DefaultDynamicFontProvider: DynamicFontProvider { return UIFont.preferredFont(forTextStyle: textStyle) } - @available(iOS 13.0, tvOS 13.0, *) func font(forTextStyle textStyle: Font.TextStyle) -> Font { return Font.system(textStyle) } @@ -91,7 +86,6 @@ private struct DefaultDynamicFontProvider: DynamicFontProvider { private struct CustomFontDynamicFontProvider: DynamicFontProvider { let fontDescription: FontDescription - private let fontSizeHelper = FontSizeHelper() // MARK: - DynamicFontProvider @@ -104,7 +98,6 @@ private struct CustomFontDynamicFontProvider: DynamicFontProvider { } } - @available(iOS 13.0, tvOS 13.0, *) func font(forTextStyle textStyle: Font.TextStyle) -> Font { do { return try throwingFont(forTextStyle: textStyle) @@ -125,38 +118,17 @@ private struct CustomFontDynamicFontProvider: DynamicFontProvider { return currentContentSizeCategory } - @available(iOS 13.0, tvOS 13.0, *) private func throwingFont(forTextStyle textStyle: Font.TextStyle) throws -> Font { let styleDescription = try fontDescription.fontStyleDescription(for: textStyle) - let customFont: Font - if #available(iOS 14.0, tvOS 14.0, *) { - customFont = Font.custom(styleDescription.name, size: styleDescription.size, relativeTo: textStyle) - } else { - customFont = Font.custom(styleDescription.name, size: styleDescription.size) - } - return customFont + return Font.custom(styleDescription.name, size: styleDescription.size, relativeTo: textStyle) } private func throwingFont(forTextStyle textStyle: UIFont.TextStyle) throws -> UIFont { let styleDescription = try fontDescription.fontStyleDescription(for: textStyle) let customFont = UIFont(name: styleDescription.name, size: styleDescription.size) - if #available(iOS 11.0, tvOS 11.0, *) { - let font = try (customFont ?? systemFont(weightName: styleDescription.name, size: styleDescription.size)) - let fontMetrics = UIFontMetrics(forTextStyle: textStyle) - return fontMetrics.scaledFont(for: font) - } else { - let size = fontSizeHelper.fontSize( - matchingSize: styleDescription.size, - withStyle: textStyle, - contentSizeCategory: currentSpecifiedContentSizeCategory - ) - guard customFont != nil else { - // TODO: (Benjamin Lavialle) 2018-03-15 Check custom font existency, otherwise fallback to system font - return try systemFont(weightName: styleDescription.name, size: size) - } - let descriptor = UIFontDescriptor(name: styleDescription.name, size: size) - return UIFont(descriptor: descriptor, size: 0.0) - } + let font = try (customFont ?? systemFont(weightName: styleDescription.name, size: styleDescription.size)) + let fontMetrics = UIFontMetrics(forTextStyle: textStyle) + return fontMetrics.scaledFont(for: font) } private func systemFont(weightName: String, size: CGFloat) throws -> UIFont { @@ -194,194 +166,3 @@ private extension UIFont.Weight { } } } - -private struct FontSizeHelper { - - // (Benjamin Lavialle) 2017-10-20 Provides a font size according to the Apple default font size for categories - func fontSize(matchingSize size: CGFloat, - withStyle style: UIFont.TextStyle, - contentSizeCategory: UIContentSizeCategory) -> CGFloat { - guard - let contentSizeSizes = fontSizeMatrix[style] else { - assertionFailure("[DynamicFont] Missing style \(style) inFontSizeHelper") - return 0.0 - } - guard - let matchingSize = contentSizeSizes[contentSizeCategory], - let defaultSize = contentSizeSizes[.large] else { - assertionFailure("[DynamicFont] Missing size category \(contentSizeCategory) for style \(style)") - return 0.0 - } - let size = Int(size * matchingSize / defaultSize) - return CGFloat(size) - } - - // (Benjamin Lavialle) 2017-10-20 Font sizes from Apple system font - // swiftlint:disable:next line_length - private let fontSizeMatrix: [UIFont.TextStyle: [UIContentSizeCategory: CGFloat]] = FontSizeHelper.createFontSizeMatrix() - - // swiftlint:disable:next function_body_length - private static func createFontSizeMatrix() -> [UIFont.TextStyle: [UIContentSizeCategory: CGFloat]] { - var fontSizeMatrix: [UIFont.TextStyle: [UIContentSizeCategory: CGFloat]] = [ - .headline: [ - .accessibilityExtraExtraExtraLarge: 53.0, - .accessibilityExtraExtraLarge: 47.0, - .accessibilityExtraLarge: 40.0, - .accessibilityLarge: 33.0, - .accessibilityMedium: 28.0, - .extraExtraExtraLarge: 23.0, - .extraExtraLarge: 21.0, - .extraLarge: 19.0, - .large: 17.0, - .medium: 16.0, - .small: 15.0, - .extraSmall: 14.0 - ], - .body: [ - .accessibilityExtraExtraExtraLarge: 53.0, - .accessibilityExtraExtraLarge: 47.0, - .accessibilityExtraLarge: 40.0, - .accessibilityLarge: 33.0, - .accessibilityMedium: 28.0, - .extraExtraExtraLarge: 23.0, - .extraExtraLarge: 21.0, - .extraLarge: 19.0, - .large: 17.0, - .medium: 16.0, - .small: 15.0, - .extraSmall: 14.0 - ], - .subheadline: [ - .accessibilityExtraExtraExtraLarge: 49.0, - .accessibilityExtraExtraLarge: 42.0, - .accessibilityExtraLarge: 36.0, - .accessibilityLarge: 30.0, - .accessibilityMedium: 25.0, - .extraExtraExtraLarge: 21.0, - .extraExtraLarge: 19.0, - .extraLarge: 17.0, - .large: 15.0, - .medium: 14.0, - .small: 13.0, - .extraSmall: 12.0 - ], - .footnote: [ - .accessibilityExtraExtraExtraLarge: 44.0, - .accessibilityExtraExtraLarge: 38.0, - .accessibilityExtraLarge: 33.0, - .accessibilityLarge: 27.0, - .accessibilityMedium: 23.0, - .extraExtraExtraLarge: 19.0, - .extraExtraLarge: 17.0, - .extraLarge: 15.0, - .large: 13.0, - .medium: 12.0, - .small: 12.0, - .extraSmall: 12.0 - ], - .caption1: [ - .accessibilityExtraExtraExtraLarge: 43.0, - .accessibilityExtraExtraLarge: 37.0, - .accessibilityExtraLarge: 32.0, - .accessibilityLarge: 26.0, - .accessibilityMedium: 22.0, - .extraExtraExtraLarge: 18.0, - .extraExtraLarge: 16.0, - .extraLarge: 14.0, - .large: 12.0, - .medium: 11.0, - .small: 11.0, - .extraSmall: 11.0 - ], - .caption2: [ - .accessibilityExtraExtraExtraLarge: 40.0, - .accessibilityExtraExtraLarge: 34.0, - .accessibilityExtraLarge: 29.0, - .accessibilityLarge: 24.0, - .accessibilityMedium: 20.0, - .extraExtraExtraLarge: 17.0, - .extraExtraLarge: 15.0, - .extraLarge: 13.0, - .large: 11.0, - .medium: 11.0, - .small: 11.0, - .extraSmall: 11.0 - ] - ] - fontSizeMatrix[.title1] = [ - .accessibilityExtraExtraExtraLarge: 58.0, - .accessibilityExtraExtraLarge: 53.0, - .accessibilityExtraLarge: 48.0, - .accessibilityLarge: 43.0, - .accessibilityMedium: 38.0, - .extraExtraExtraLarge: 34.0, - .extraExtraLarge: 32.0, - .extraLarge: 30.0, - .large: 28.0, - .medium: 27.0, - .small: 26.0, - .extraSmall: 25.0 - ] - fontSizeMatrix[.title2] = [ - .accessibilityExtraExtraExtraLarge: 56.0, - .accessibilityExtraExtraLarge: 50.0, - .accessibilityExtraLarge: 44.0, - .accessibilityLarge: 39.0, - .accessibilityMedium: 34.0, - .extraExtraExtraLarge: 28.0, - .extraExtraLarge: 26.0, - .extraLarge: 24.0, - .large: 22.0, - .medium: 21.0, - .small: 20.0, - .extraSmall: 19.0 - ] - fontSizeMatrix[.title3] = [ - .accessibilityExtraExtraExtraLarge: 55.0, - .accessibilityExtraExtraLarge: 49.0, - .accessibilityExtraLarge: 43.0, - .accessibilityLarge: 37.0, - .accessibilityMedium: 31.0, - .extraExtraExtraLarge: 26.0, - .extraExtraLarge: 24.0, - .extraLarge: 22.0, - .large: 20.0, - .medium: 19.0, - .small: 18.0, - .extraSmall: 17.0 - ] - fontSizeMatrix[.callout] = [ - .accessibilityExtraExtraExtraLarge: 51.0, - .accessibilityExtraExtraLarge: 44.0, - .accessibilityExtraLarge: 38.0, - .accessibilityLarge: 32.0, - .accessibilityMedium: 26.0, - .extraExtraExtraLarge: 22.0, - .extraExtraLarge: 20.0, - .extraLarge: 18.0, - .large: 16.0, - .medium: 15.0, - .small: 14.0, - .extraSmall: 13.0 - ] - #if os(iOS) - if #available(iOS 11.0, *) { - fontSizeMatrix[.largeTitle] = [ - .accessibilityExtraExtraExtraLarge: 60.0, - .accessibilityExtraExtraLarge: 56.0, - .accessibilityExtraLarge: 52.0, - .accessibilityLarge: 48.0, - .accessibilityMedium: 44.0, - .extraExtraExtraLarge: 40.0, - .extraExtraLarge: 38.0, - .extraLarge: 36.0, - .large: 34.0, - .medium: 33.0, - .small: 32.0, - .extraSmall: 31.0 - ] - } - #endif - return fontSizeMatrix - } -} diff --git a/Modules/ADUtils/FontDescription.swift b/Modules/ADUtils/FontDescription.swift index e011597..d7b2729 100644 --- a/Modules/ADUtils/FontDescription.swift +++ b/Modules/ADUtils/FontDescription.swift @@ -68,7 +68,6 @@ struct FontDescription { - parameter fontTextStyle: the text style - returns: the FontStyleDescription corresponding to the text style, as specified in the plist */ - @available(iOS 13.0, tvOS 13.0, *) func fontStyleDescription(for fontTextStyle: Font.TextStyle) throws -> FontStyleDescription { try fontStyleDescription(for: fontTextStyle.rawValue) } @@ -103,7 +102,6 @@ enum FontDescriptionError: Error { case fontMissing } -@available(iOS 13.0, tvOS 13.0, *) fileprivate extension Font.TextStyle { // MARK: - Font diff --git a/Modules/ADUtils/NSDirectionalEdgeInsets+Utilities.swift b/Modules/ADUtils/NSDirectionalEdgeInsets+Utilities.swift index b24739d..646a16f 100644 --- a/Modules/ADUtils/NSDirectionalEdgeInsets+Utilities.swift +++ b/Modules/ADUtils/NSDirectionalEdgeInsets+Utilities.swift @@ -8,8 +8,6 @@ import Foundation import UIKit -@available(iOS 13.0, *) -@available(tvOSApplicationExtension 13.0, *) extension NSDirectionalEdgeInsets { /** diff --git a/Modules/ADUtils/UIImage+Color.swift b/Modules/ADUtils/UIImage+Color.swift index 7578fca..ff4e3fa 100644 --- a/Modules/ADUtils/UIImage+Color.swift +++ b/Modules/ADUtils/UIImage+Color.swift @@ -18,34 +18,29 @@ public extension UIImage { static func ad_filled(with color: UIColor, size: CGSize = CGSize(width: 1, height: 1), scale: CGFloat = 1.0) -> UIImage? { - if #available(iOS 13.0, tvOS 13.0, *) { - let lightModeImage = generateImage( - withColor: color, - size: size, - scale: scale, - userInterfaceStyle: .light + let lightModeImage = generateImage( + withColor: color, + size: size, + scale: scale, + userInterfaceStyle: .light + ) + let darkModeImage = generateImage( + withColor: color, + size: size, + scale: scale, + userInterfaceStyle: .dark + ) + if let darkImage = darkModeImage { + lightModeImage?.imageAsset?.register( + darkImage, + with: UITraitCollection(userInterfaceStyle: .dark) ) - let darkModeImage = generateImage( - withColor: color, - size: size, - scale: scale, - userInterfaceStyle: .dark - ) - if let darkImage = darkModeImage { - lightModeImage?.imageAsset?.register( - darkImage, - with: UITraitCollection(userInterfaceStyle: .dark) - ) - } - return lightModeImage - } else { - return generateImage(withColor: color, size: size, scale: scale) } + return lightModeImage } // MARK: - Private - @available(iOS 13.0, tvOS 13.0, *) private static func generateImage(withColor color: UIColor, size: CGSize, scale: CGFloat, diff --git a/Modules/ADUtils/UILayoutGuide+Constraints.swift b/Modules/ADUtils/UILayoutGuide+Constraints.swift index 065ecab..d94e8e4 100644 --- a/Modules/ADUtils/UILayoutGuide+Constraints.swift +++ b/Modules/ADUtils/UILayoutGuide+Constraints.swift @@ -689,8 +689,6 @@ extension UILayoutGuide { } } -@available(iOS 13.0, tvOS 13.0, *) -@available(tvOSApplicationExtension 13.0, *) extension UILayoutGuide { /** Add constraints to pin self in layout guide diff --git a/Modules/ADUtils/UINavigationItem+BackItem.swift b/Modules/ADUtils/UINavigationItem+BackItem.swift index 15c8e37..7ac04af 100644 --- a/Modules/ADUtils/UINavigationItem+BackItem.swift +++ b/Modules/ADUtils/UINavigationItem+BackItem.swift @@ -12,15 +12,11 @@ public extension UINavigationItem { /** * Hides the back bar button item title. * - * - Important: This method modifies the `backBarButtonItem` of the item. + * - Important: This method modifies the `backButtonDisplayMode` of the item. */ @available(tvOS, unavailable) func ad_hideBackButtonTitle() { - if #available(iOS 14.0, *) { - backButtonDisplayMode = .minimal - } else { - backBarButtonItem = .empty - } + backButtonDisplayMode = .minimal } } diff --git a/Modules/ADUtils/UIView+Constraints.swift b/Modules/ADUtils/UIView+Constraints.swift index afdf953..df29a8c 100644 --- a/Modules/ADUtils/UIView+Constraints.swift +++ b/Modules/ADUtils/UIView+Constraints.swift @@ -361,8 +361,6 @@ extension UIView { } } -@available(iOS 13.0, tvOS 13.0, *) -@available(tvOSApplicationExtension 13.0, *) extension UIView { /** diff --git a/Modules/ADUtils/UIView+LayoutGuideConstraints.swift b/Modules/ADUtils/UIView+LayoutGuideConstraints.swift index c3a518e..4001967 100644 --- a/Modules/ADUtils/UIView+LayoutGuideConstraints.swift +++ b/Modules/ADUtils/UIView+LayoutGuideConstraints.swift @@ -395,7 +395,6 @@ extension UIView { - parameter priority: The layout priority used for the constraints created */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_pinToSuperviewSafeAreaLayoutGuideWithEdges:insets:priority:) @discardableResult public func ad_pinToSuperviewSafeAreaLayoutGuide(edges: UIRectEdge, @@ -415,7 +414,6 @@ extension UIView { - parameter priority: The layout priority used for the constraints created */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_pinToSuperviewSafeAreaLayoutGuideWithInsets:priority:) @discardableResult public func ad_pinToSuperviewSafeAreaLayoutGuide(insets: UIEdgeInsets, @@ -430,7 +428,6 @@ extension UIView { Add constraints to pin self in superview's safe area layout guide */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_pinToSuperviewSafeAreaLayoutGuide) @discardableResult public func ad_pinToSuperviewSafeAreaLayoutGuide() -> [NSLayoutConstraint] { @@ -446,7 +443,6 @@ extension UIView { - parameter insets: UIEdgeInsets to apply for each edge */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_pinToSuperviewSafeAreaLayoutGuideWithInsets:) @discardableResult public func ad_pinToSuperviewSafeAreaLayoutGuide(insets: UIEdgeInsets) -> [NSLayoutConstraint] { @@ -462,7 +458,6 @@ extension UIView { - parameter edges: Edges to pin the view in the layout guide */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_pinToSuperviewSafeAreaLayoutGuideWithEdges:) @discardableResult public func ad_pinToSuperviewSafeAreaLayoutGuide(edges: UIRectEdge) -> [NSLayoutConstraint] { @@ -480,7 +475,6 @@ extension UIView { - parameter insets: UIEdgeInsets to apply for each edge */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_pinToSuperviewSafeAreaLayoutGuideWithEdges:insets:) @discardableResult public func ad_pinToSuperviewSafeAreaLayoutGuide(edges: UIRectEdge, @@ -499,7 +493,6 @@ extension UIView { - parameter priority: The layout priority used for the constraint created */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_centerInSuperviewSafeAreaLayoutGuideAlongAxis:priority:) @discardableResult public func ad_centerInSuperviewSafeAreaLayoutGuide(along axis: NSLayoutConstraint.Axis, @@ -516,7 +509,6 @@ extension UIView { - parameter axis: Axis to center the view along in layout guide */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_centerInSuperviewSafeAreaLayoutGuideAlongAxis:) @discardableResult public func ad_centerInSuperviewSafeAreaLayoutGuide(along axis: NSLayoutConstraint.Axis) -> [NSLayoutConstraint] { @@ -532,7 +524,6 @@ extension UIView { - parameter priority: The layout priority used for the constraint created */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_centerInSuperviewSafeAreaLayoutGuideWithPriority:) @discardableResult public func ad_centerInSuperviewSafeAreaLayoutGuide(priority: UILayoutPriority) -> [NSLayoutConstraint] { @@ -546,7 +537,6 @@ extension UIView { Add constraints to center self in superview's safe area layout guide along specified axis */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_centerInSuperviewSafeAreaLayoutGuide) @discardableResult public func ad_centerInSuperviewSafeAreaLayoutGuide() -> [NSLayoutConstraint] { @@ -566,7 +556,6 @@ extension UIView { - parameter priority: The layout priority used for the constraint created */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_constrainInSuperviewSafeAreaLayoutGuideWithEdges:insets:priority:) @discardableResult public func ad_constrainInSuperviewSafeAreaLayoutGuide(edges: UIRectEdge, @@ -582,7 +571,6 @@ extension UIView { Add max constraints to edges of superview's safe area layout guide */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_constrainInSuperviewSafeAreaLayoutGuide) @discardableResult public func ad_constrainInSuperviewSafeAreaLayoutGuide() -> [NSLayoutConstraint] { @@ -598,7 +586,6 @@ extension UIView { - parameter insets: UIEdgeInsets to apply for each edge */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_constrainInSuperviewSafeAreaLayoutGuideWithInsets:) @discardableResult public func ad_constrainInSuperviewSafeAreaLayoutGuide(insets: UIEdgeInsets) -> [NSLayoutConstraint] { @@ -614,7 +601,6 @@ extension UIView { - parameter edges: Edges to pin the view in layout guide */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_constrainInSuperviewSafeAreaLayoutGuideWithEdges:) @discardableResult public func ad_constrainInSuperviewSafeAreaLayoutGuide(edges: UIRectEdge) -> [NSLayoutConstraint] { @@ -632,7 +618,6 @@ extension UIView { - parameter insets: UIEdgeInsets to apply for each edge */ - @available(iOS 11.0, tvOS 11.0, *) @objc(ad_constrainInSuperviewSafeAreaLayoutGuideWithEdges:insets:) @discardableResult public func ad_constrainInSuperviewSafeAreaLayoutGuide(edges: UIRectEdge, @@ -644,8 +629,6 @@ extension UIView { } } -@available(iOS 13.0, tvOS 13.0, *) -@available(tvOSApplicationExtension 13.0, *) extension UIView { /** diff --git a/Modules/ADUtils/UIViewController+ChildInsertion.swift b/Modules/ADUtils/UIViewController+ChildInsertion.swift index 0e63c76..cc6b3e5 100644 --- a/Modules/ADUtils/UIViewController+ChildInsertion.swift +++ b/Modules/ADUtils/UIViewController+ChildInsertion.swift @@ -63,8 +63,6 @@ extension UIViewController { } } -@available(iOS 13.0, tvOS 13.0, *) -@available(tvOSApplicationExtension 13.0, *) extension UIViewController { /** diff --git a/Modules/ADUtils_security/SecureArchiver.swift b/Modules/ADUtils_security/SecureArchiver.swift index 0049cd5..3bfc73b 100644 --- a/Modules/ADUtils_security/SecureArchiver.swift +++ b/Modules/ADUtils_security/SecureArchiver.swift @@ -19,7 +19,6 @@ public protocol StorageArchiver { func deleteValue(forKey key: String) } -@available(iOS 13.0, tvOS 13.0, *) public class SecureArchiver { private enum Constants { From eb1741008599a278edf1f8fb1cabd9956ada4cc8 Mon Sep 17 00:00:00 2001 From: Alexandre Podlewski Date: Fri, 20 Oct 2023 14:19:59 +0200 Subject: [PATCH 3/5] Fix warning about ios version when building test app --- Podfile | 3 +++ Podfile.lock | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Podfile b/Podfile index 289b89d..a89c773 100644 --- a/Podfile +++ b/Podfile @@ -31,6 +31,9 @@ post_install do |installer| # Enable complete concurrency checks config.build_settings['SWIFT_STRICT_CONCURRENCY'] = "complete" end + + # Use same iOS target version on all pods + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "14.0" end end end diff --git a/Podfile.lock b/Podfile.lock index 2a5acf9..19fb34f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -36,6 +36,6 @@ SPEC CHECKSUMS: Quick: efab97aca76d60be86c15daa533b2cdfbe1a74d3 SwiftLint: 4fa9579c63416865179bc416f0a92d55f009600d -PODFILE CHECKSUM: a87d7020e3dc0edf7a63dd3f642255f1bc8dcd8f +PODFILE CHECKSUM: 1e4b54685f6d25641e549bec37c05be8ff45c1b7 COCOAPODS: 1.13.0 From 8211f87883dee34b1f7f44a09aad2fbbcb6b76dd Mon Sep 17 00:00:00 2001 From: Alexandre Podlewski Date: Fri, 20 Oct 2023 14:20:52 +0200 Subject: [PATCH 4/5] Remove dead code --- ADUtilsTests/LayoutTests/ViewLayoutTest.swift | 1 - Modules/ADUtils_security/SecureArchiver.swift | 1 - 2 files changed, 2 deletions(-) diff --git a/ADUtilsTests/LayoutTests/ViewLayoutTest.swift b/ADUtilsTests/LayoutTests/ViewLayoutTest.swift index d4d2986..c1eb78e 100644 --- a/ADUtilsTests/LayoutTests/ViewLayoutTest.swift +++ b/ADUtilsTests/LayoutTests/ViewLayoutTest.swift @@ -95,7 +95,6 @@ class ViewLayout: QuickSpec { addLabelInView(headerFooter.contentView) let expectedHeight = 1218.0 // When - let height = headerFooter.ad_preferredContentViewLayoutHeight(fittingWidth: width) let layoutEngineHeight = headerFooter.ad_preferredContentViewLayoutHeight( fittingWidth: width, computationType: .layoutEngine diff --git a/Modules/ADUtils_security/SecureArchiver.swift b/Modules/ADUtils_security/SecureArchiver.swift index 3bfc73b..bdaf065 100644 --- a/Modules/ADUtils_security/SecureArchiver.swift +++ b/Modules/ADUtils_security/SecureArchiver.swift @@ -23,7 +23,6 @@ public class SecureArchiver { private enum Constants { static let passphrasePrefix = "cryptoKeyPassphrase_" - static let installedPrefix = "appIsInstalled_" } private enum SecureArchiverError: Error { From 12813e6b758ac8bafe212057167092d60ce109f6 Mon Sep 17 00:00:00 2001 From: Alexandre Podlewski Date: Fri, 20 Oct 2023 18:05:01 +0200 Subject: [PATCH 5/5] Remove additional check for iOS 14 in tests --- ADUtilsTests/DynamicFontTest.swift | 36 ++--- .../LayoutGuideConstraintsTests.swift | 4 +- ADUtilsTests/UIImageColorTests.swift | 53 ++++---- .../UINavigationItemBackItemTests.swift | 6 +- .../ViewInsertionWithMarginTest.swift | 128 +++++++++--------- 5 files changed, 104 insertions(+), 123 deletions(-) diff --git a/ADUtilsTests/DynamicFontTest.swift b/ADUtilsTests/DynamicFontTest.swift index 1c4de86..93d1196 100644 --- a/ADUtilsTests/DynamicFontTest.swift +++ b/ADUtilsTests/DynamicFontTest.swift @@ -67,9 +67,7 @@ class DynamicFontTest: QuickSpec { let labels = types.map { (type) -> UILabel in let label = UILabel() label.font = UIFont.ad_mainFont(forTextStyle: type) - if #available(iOS 11.0, *) { - label.adjustsFontForContentSizeCategory = true - } + label.adjustsFontForContentSizeCategory = true label.text = "Lorem sizzle pimpin' sit amizzle" label.numberOfLines = 0 return label @@ -116,24 +114,20 @@ class DynamicFontTest: QuickSpec { } } it("should layout labels properly") { - if #available(iOS 14.0, *) { - let view = DynamicFontsView() - assertSnapshot( - matching: view, - as: .image(layout: .fixed(width: 200, height: 1000)), - named: "SwiftUIDynamicFontLayoutTest" - ) - assertSnapshot( - matching: view, - as: .image( - layout: .fixed(width: 200, height: 1000), - traits: UITraitCollection(preferredContentSizeCategory: .extraExtraExtraLarge) - ), - named: "SwiftUIDynamicFontLayoutXXLTest" - ) - } else { - throw XCTSkip("title2, title3, caption2 are only available on iOS 14") - } + let view = DynamicFontsView() + assertSnapshot( + matching: view, + as: .image(layout: .fixed(width: 200, height: 1000)), + named: "SwiftUIDynamicFontLayoutTest" + ) + assertSnapshot( + matching: view, + as: .image( + layout: .fixed(width: 200, height: 1000), + traits: UITraitCollection(preferredContentSizeCategory: .extraExtraExtraLarge) + ), + named: "SwiftUIDynamicFontLayoutXXLTest" + ) } } } diff --git a/ADUtilsTests/LayoutGuideConstraintsTests.swift b/ADUtilsTests/LayoutGuideConstraintsTests.swift index 3408cc4..45452ea 100644 --- a/ADUtilsTests/LayoutGuideConstraintsTests.swift +++ b/ADUtilsTests/LayoutGuideConstraintsTests.swift @@ -16,9 +16,7 @@ class LayoutGuideConstraintsTests: QuickSpec { override class func spec() { standardEdgesSpec() - if #available(iOS 13, *) { - directionalEdgesSpec() - } + directionalEdgesSpec() } // MARK: - Private diff --git a/ADUtilsTests/UIImageColorTests.swift b/ADUtilsTests/UIImageColorTests.swift index cd231c5..8d38700 100644 --- a/ADUtilsTests/UIImageColorTests.swift +++ b/ADUtilsTests/UIImageColorTests.swift @@ -57,37 +57,34 @@ class UIImageColorTests: QuickSpec { assertSnapshot(matching: imageView, as: .image(traits: UITraitCollection(displayScale: scale)), named: "UIImageColorRedWithScale") } - if #available(iOS 13.0, *) { - - it("should create images for light and dark modes") { - // Given - let color = UIColor { traitCollection in - switch traitCollection.userInterfaceStyle { - case .dark: - return .blue - case .light, - .unspecified: - return .red - @unknown default: - fatalError("Case not handled") - } + it("should create images for light and dark modes") { + // Given + let color = UIColor { traitCollection in + switch traitCollection.userInterfaceStyle { + case .dark: + return .blue + case .light, + .unspecified: + return .red + @unknown default: + fatalError("Case not handled") } - let size = CGSize(width: 10, height: 20) + } + let size = CGSize(width: 10, height: 20) - // When - let image = UIImage.ad_filled(with: color, size: size) + // When + let image = UIImage.ad_filled(with: color, size: size) - // Then - // Can't create a snapshot test case here, as userInterfaceStyle is not working in XCTest - // cf https://github.com/uber/ios-snapshot-test-case/issues/122 - expect(image).toNot(beNil()) - expect(image?.imageAsset).toNot(beNil()) - let lightImage = image?.imageAsset?.image(with: UITraitCollection(userInterfaceStyle: .light)) - let darkImage = image?.imageAsset?.image(with: UITraitCollection(userInterfaceStyle: .dark)) - expect(lightImage).toNot(beNil()) - expect(darkImage).toNot(beNil()) - expect(lightImage).toNot(equal(darkImage)) - } + // Then + // Can't create a snapshot test case here, as userInterfaceStyle is not working in XCTest + // cf https://github.com/uber/ios-snapshot-test-case/issues/122 + expect(image).toNot(beNil()) + expect(image?.imageAsset).toNot(beNil()) + let lightImage = image?.imageAsset?.image(with: UITraitCollection(userInterfaceStyle: .light)) + let darkImage = image?.imageAsset?.image(with: UITraitCollection(userInterfaceStyle: .dark)) + expect(lightImage).toNot(beNil()) + expect(darkImage).toNot(beNil()) + expect(lightImage).toNot(equal(darkImage)) } } } diff --git a/ADUtilsTests/UINavigationItemBackItemTests.swift b/ADUtilsTests/UINavigationItemBackItemTests.swift index 0c38a7c..34ed9f7 100644 --- a/ADUtilsTests/UINavigationItemBackItemTests.swift +++ b/ADUtilsTests/UINavigationItemBackItemTests.swift @@ -21,11 +21,7 @@ class UINavigationItemBackItemTests: QuickSpec { item.ad_hideBackButtonTitle() // Then - if #available(iOS 14.0, *) { - expect(item.backButtonTitle).to(beNil()) - } else { - expect(item.backBarButtonItem?.title).to(beEmpty()) - } + expect(item.backButtonTitle).to(beNil()) } } diff --git a/ADUtilsTests/ViewInsertionWithMarginTest.swift b/ADUtilsTests/ViewInsertionWithMarginTest.swift index a22510d..951fe33 100644 --- a/ADUtilsTests/ViewInsertionWithMarginTest.swift +++ b/ADUtilsTests/ViewInsertionWithMarginTest.swift @@ -34,9 +34,7 @@ class ViewInsertionWithMargin: QuickSpec { override class func spec() { standardEdgesSpec() - if #available(iOS 13, *) { - directionalEdgesSpec() - } + directionalEdgesSpec() } // MARK: - Private @@ -213,69 +211,67 @@ class ViewInsertionWithMargin: QuickSpec { } } - if #available(iOS 11.0, *) { - describe("Constrain in superview's safe area layout guide") { - var viewController: UIViewController! - var view: UIView! - var subview: UIView! - let insets = UIEdgeInsets(top: 10.0, left: 20.0, bottom: 30.0, right: 40.0) - - beforeEach { - viewController = UIViewController() - viewController.additionalSafeAreaInsets = UIEdgeInsets(top: 40, left: 30, bottom: 20, right: 10) - viewController.view = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 200.0)) - view = viewController.view - view.backgroundColor = UIColor.white - subview = IntrinsicContentSizeView(contentSize: CGSize(width: 500, height: 500)) - subview.backgroundColor = UIColor.red - view.addSubview(subview) - - //(Benjamin Lavialle) 2020-03-19 Adding the view controller to a window is required to have - // safe area insets. The snapshots are then device agnostic. - UIApplication.shared.keyWindow?.rootViewController = viewController - } - - it("should constrain in superview pin bottom left") { - subview.ad_pinToSuperviewSafeAreaLayoutGuide(edges: [.bottom, .left], insets: insets) - subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.top, .right], insets: insets) - assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaPinBottomLeft") - } - - it("should constrain in superview pin bottom right") { - subview.ad_pinToSuperviewSafeAreaLayoutGuide(edges: [.bottom, .right], insets: insets) - subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.top, .left], insets: insets) - assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaPinBottomRight") - } - - it("should constrain in superview pin top left") { - subview.ad_pinToSuperviewSafeAreaLayoutGuide(edges: [.top, .left], insets: insets) - subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.bottom, .right], insets: insets) - assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaPinTopLeft") - } - - it("should constrain in superview pin top right") { - subview.ad_pinToSuperviewSafeAreaLayoutGuide(edges: [.top, .right], insets: insets) - subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.bottom, .left], insets: insets) - assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaPinTopRight") - } - - it("should constrain in superview") { - subview.ad_centerInSuperviewSafeAreaLayoutGuide() - subview.ad_constrainInSuperviewSafeAreaLayoutGuide() - assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeArea") - } - - it("should constrain in superview with insets") { - subview.ad_centerInSuperviewSafeAreaLayoutGuide() - subview.ad_constrainInSuperviewSafeAreaLayoutGuide(insets: UIEdgeInsets(value: 100)) - assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaWithInsets") - } - - it("should constrain in superview with left edge") { - subview.ad_centerInSuperviewSafeAreaLayoutGuide() - subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.left]) - assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaWithLeftEdge") - } + describe("Constrain in superview's safe area layout guide") { + var viewController: UIViewController! + var view: UIView! + var subview: UIView! + let insets = UIEdgeInsets(top: 10.0, left: 20.0, bottom: 30.0, right: 40.0) + + beforeEach { + viewController = UIViewController() + viewController.additionalSafeAreaInsets = UIEdgeInsets(top: 40, left: 30, bottom: 20, right: 10) + viewController.view = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 200.0)) + view = viewController.view + view.backgroundColor = UIColor.white + subview = IntrinsicContentSizeView(contentSize: CGSize(width: 500, height: 500)) + subview.backgroundColor = UIColor.red + view.addSubview(subview) + + //(Benjamin Lavialle) 2020-03-19 Adding the view controller to a window is required to have + // safe area insets. The snapshots are then device agnostic. + UIApplication.shared.keyWindow?.rootViewController = viewController + } + + it("should constrain in superview pin bottom left") { + subview.ad_pinToSuperviewSafeAreaLayoutGuide(edges: [.bottom, .left], insets: insets) + subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.top, .right], insets: insets) + assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaPinBottomLeft") + } + + it("should constrain in superview pin bottom right") { + subview.ad_pinToSuperviewSafeAreaLayoutGuide(edges: [.bottom, .right], insets: insets) + subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.top, .left], insets: insets) + assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaPinBottomRight") + } + + it("should constrain in superview pin top left") { + subview.ad_pinToSuperviewSafeAreaLayoutGuide(edges: [.top, .left], insets: insets) + subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.bottom, .right], insets: insets) + assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaPinTopLeft") + } + + it("should constrain in superview pin top right") { + subview.ad_pinToSuperviewSafeAreaLayoutGuide(edges: [.top, .right], insets: insets) + subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.bottom, .left], insets: insets) + assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaPinTopRight") + } + + it("should constrain in superview") { + subview.ad_centerInSuperviewSafeAreaLayoutGuide() + subview.ad_constrainInSuperviewSafeAreaLayoutGuide() + assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeArea") + } + + it("should constrain in superview with insets") { + subview.ad_centerInSuperviewSafeAreaLayoutGuide() + subview.ad_constrainInSuperviewSafeAreaLayoutGuide(insets: UIEdgeInsets(value: 100)) + assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaWithInsets") + } + + it("should constrain in superview with left edge") { + subview.ad_centerInSuperviewSafeAreaLayoutGuide() + subview.ad_constrainInSuperviewSafeAreaLayoutGuide(edges: [.left]) + assertSnapshot(matching: view, as: .image, named: "ConstrainInSuperviewSafeAreaWithLeftEdge") } } }