From c0a7133ac8814fb4b9eb79542fbe94fb10f866e6 Mon Sep 17 00:00:00 2001 From: Julio Alorro Date: Thu, 14 Mar 2019 13:03:12 +0100 Subject: [PATCH 1/6] Swift 4.2 --- LayoutKit.podspec | 1 - LayoutKit.xcodeproj/project.pbxproj | 4 ++-- Sources/Internal/NSAttributedStringExtension.swift | 2 +- Sources/Layouts/ButtonLayout.swift | 2 +- Sources/Layouts/TextViewLayout.swift | 2 +- Sources/Text.swift | 2 +- Sources/Views/ReloadableView.swift | 4 ++-- .../Views/ReloadableViewLayoutAdapter+UICollectionView.swift | 4 ++-- Sources/Views/StackView.swift | 2 +- 9 files changed, 11 insertions(+), 12 deletions(-) diff --git a/LayoutKit.podspec b/LayoutKit.podspec index e1251821..138bfc88 100644 --- a/LayoutKit.podspec +++ b/LayoutKit.podspec @@ -42,4 +42,3 @@ Pod::Spec.new do |spec| ] end - diff --git a/LayoutKit.xcodeproj/project.pbxproj b/LayoutKit.xcodeproj/project.pbxproj index a95b5e24..fb5a6c31 100644 --- a/LayoutKit.xcodeproj/project.pbxproj +++ b/LayoutKit.xcodeproj/project.pbxproj @@ -1812,7 +1812,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; - SWIFT_VERSION = 4.1; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -1845,7 +1845,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_VERSION = 4.1; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Sources/Internal/NSAttributedStringExtension.swift b/Sources/Internal/NSAttributedStringExtension.swift index 51a7b0f0..673f789e 100644 --- a/Sources/Internal/NSAttributedStringExtension.swift +++ b/Sources/Internal/NSAttributedStringExtension.swift @@ -12,7 +12,7 @@ extension NSAttributedString { /// Returns a new NSAttributedString with a given font and the same attributes. func with(font: UIFont) -> NSAttributedString { - let fontAttribute = [NSAttributedStringKey.font: font] + let fontAttribute = [NSAttributedString.Key.font: font] let attributedTextWithFont = NSMutableAttributedString(string: string, attributes: fontAttribute) let fullRange = NSMakeRange(0, (string as NSString).length) attributedTextWithFont.beginEditing() diff --git a/Sources/Layouts/ButtonLayout.swift b/Sources/Layouts/ButtonLayout.swift index f1189548..35e6dbf1 100644 --- a/Sources/Layouts/ButtonLayout.swift +++ b/Sources/Layouts/ButtonLayout.swift @@ -292,7 +292,7 @@ public enum ButtonLayoutType { case infoDark case contactAdd - public var buttonType: UIButtonType { + public var buttonType: UIButton.ButtonType { switch (self) { case .custom: return .custom diff --git a/Sources/Layouts/TextViewLayout.swift b/Sources/Layouts/TextViewLayout.swift index b71c8ac8..5f43adf7 100644 --- a/Sources/Layouts/TextViewLayout.swift +++ b/Sources/Layouts/TextViewLayout.swift @@ -233,7 +233,7 @@ private extension Text { case .attributed(_): let text = Text.attributed(NSAttributedString( string: spaceString, - attributes: [NSAttributedStringKey.font: font])) + attributes: [NSAttributedString.Key.font: font])) size = text.textSize(within: maxSize, font: font) case .unattributed(_): diff --git a/Sources/Text.swift b/Sources/Text.swift index 0166104f..e50e1d33 100644 --- a/Sources/Text.swift +++ b/Sources/Text.swift @@ -39,7 +39,7 @@ public enum Text { if text.isEmpty { return .zero } - size = text.boundingRect(with: maxSize, options: options, attributes: [NSAttributedStringKey.font: font], context: nil).size + size = text.boundingRect(with: maxSize, options: options, attributes: [NSAttributedString.Key.font: font], context: nil).size } // boundingRect(with:options:attributes:) returns size to a precision of hundredths of a point, // but UILabel only returns sizes with a point precision of 1/screenDensity. diff --git a/Sources/Views/ReloadableView.swift b/Sources/Views/ReloadableView.swift index 4fb7f55c..ddb7b257 100644 --- a/Sources/Views/ReloadableView.swift +++ b/Sources/Views/ReloadableView.swift @@ -60,8 +60,8 @@ extension UICollectionView: ReloadableView { @objc open func registerViews(withReuseIdentifier reuseIdentifier: String) { register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) - register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: reuseIdentifier) - register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: reuseIdentifier) + register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: reuseIdentifier) + register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: reuseIdentifier) } @objc diff --git a/Sources/Views/ReloadableViewLayoutAdapter+UICollectionView.swift b/Sources/Views/ReloadableViewLayoutAdapter+UICollectionView.swift index 985cd0fa..87f2bcab 100644 --- a/Sources/Views/ReloadableViewLayoutAdapter+UICollectionView.swift +++ b/Sources/Views/ReloadableViewLayoutAdapter+UICollectionView.swift @@ -55,9 +55,9 @@ extension ReloadableViewLayoutAdapter: UICollectionViewDataSource { let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: reuseIdentifier, for: indexPath) let arrangement: LayoutArrangement? switch kind { - case UICollectionElementKindSectionHeader: + case UICollectionView.elementKindSectionHeader: arrangement = currentArrangement[indexPath.section].header - case UICollectionElementKindSectionFooter: + case UICollectionView.elementKindSectionFooter: arrangement = currentArrangement[indexPath.section].footer default: arrangement = nil diff --git a/Sources/Views/StackView.swift b/Sources/Views/StackView.swift index 4fdffed9..94d4bfc4 100644 --- a/Sources/Views/StackView.swift +++ b/Sources/Views/StackView.swift @@ -154,7 +154,7 @@ private struct ViewLayout: ConfigurableLayout { return Flexibility(horizontal: horizontal, vertical: vertical) } - private func flexForAxis(_ axis: UILayoutConstraintAxis) -> Flexibility.Flex { + private func flexForAxis(_ axis: NSLayoutConstraint.Axis) -> Flexibility.Flex { switch view.contentHuggingPriority(for: .horizontal) { case UILayoutPriority.required: return nil From c621842ca2d17702b60bc0cb5dbb9f3a5fec159a Mon Sep 17 00:00:00 2001 From: Julio Alorro Date: Thu, 14 Mar 2019 13:16:47 +0100 Subject: [PATCH 2/6] Updated version --- LayoutKit.podspec | 4 ++-- LayoutKit.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LayoutKit.podspec b/LayoutKit.podspec index 138bfc88..7b64dbfc 100644 --- a/LayoutKit.podspec +++ b/LayoutKit.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |spec| spec.name = 'LayoutKit' - spec.version = '10.1.0' + spec.version = '10.1.1' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'http://layoutkit.org' spec.authors = 'LinkedIn' spec.summary = 'LayoutKit is a fast view layout library for iOS, macOS, and tvOS.' - spec.source = { :git => 'https://github.com/linkedin/LayoutKit.git', :tag => spec.version } + spec.source = { :git => 'https://github.com/hooliooo/LayoutKit.git', :tag => spec.version } spec.source_files = 'Sources/**/*.swift' spec.documentation_url = 'http://layoutkit.org' diff --git a/LayoutKit.xcodeproj/project.pbxproj b/LayoutKit.xcodeproj/project.pbxproj index fb5a6c31..d055ae50 100644 --- a/LayoutKit.xcodeproj/project.pbxproj +++ b/LayoutKit.xcodeproj/project.pbxproj @@ -474,6 +474,7 @@ 0BD5F8281DB43B4500108688 /* ButtonLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonLayout.swift; sourceTree = ""; }; 0BD5F82B1DB43F9B00108688 /* ButtonLayoutTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonLayoutTests.swift; sourceTree = ""; }; 0BDDF95A1E25ACCE008B0A6F /* ReloadableViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReloadableViewTests.swift; sourceTree = ""; }; + 142C451D223A7D83002360F5 /* LayoutKit.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = LayoutKit.podspec; sourceTree = ""; }; 37BEBEF3207C23B6002BD761 /* LOKAnimation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LOKAnimation.swift; sourceTree = ""; }; 37D9D58320BF8270001A5CDD /* LOKLayoutBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LOKLayoutBuilder.h; sourceTree = ""; }; 4468A31C1E46460B00341D07 /* NSAttributedStringExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSAttributedStringExtension.swift; sourceTree = ""; }; @@ -530,7 +531,6 @@ 7EEA2AC7201D18F20077A088 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 7EEA2ACC201D1FE90077A088 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; 7EECD0612053916C003DC4B1 /* LayoutKitObjC.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LayoutKitObjC.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 7EECD0622053916C003DC4B1 /* LayoutKit-iOS copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "LayoutKit-iOS copy-Info.plist"; path = "/Users/staguer/ws/lk0/LayoutKit-iOS copy-Info.plist"; sourceTree = ""; }; A189721021B8BB3B00DDA616 /* EmbeddedLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmbeddedLayoutTests.swift; sourceTree = ""; }; AD2C36421EA5AF9500550A03 /* ReloadableViewLayoutAdapterCollectionViewOverrideTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReloadableViewLayoutAdapterCollectionViewOverrideTests.swift; sourceTree = ""; }; ADE5FCBF1EA5B5C8006A3DC2 /* ReloadableViewLayoutAdapterTableViewOverrideTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReloadableViewLayoutAdapterTableViewOverrideTests.swift; sourceTree = ""; }; @@ -664,6 +664,7 @@ 0BCB75531D871FC40065E02A = { isa = PBXGroup; children = ( + 142C451D223A7D83002360F5 /* LayoutKit.podspec */, 0B7B269E1D919A9200CD1956 /* LayoutKit.playground */, 0BCB75611D8720110065E02A /* LayoutKit */, 0BCB756C1D8720110065E02A /* LayoutKitTests */, @@ -672,7 +673,6 @@ 7EEA2AB7201D18F20077A088 /* LayoutKitObjCSampleApp */, 0BCB75601D8720110065E02A /* Products */, 7EEA2ACE201D24530077A088 /* Frameworks */, - 7EECD0622053916C003DC4B1 /* LayoutKit-iOS copy-Info.plist */, ); sourceTree = ""; }; From 882cfab94dc3cd6f359aacb11fdf805ce9b57f90 Mon Sep 17 00:00:00 2001 From: Julio Alorro Date: Thu, 14 Mar 2019 13:30:31 +0100 Subject: [PATCH 3/6] Changed swift-version --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 7d5c902e..bf77d549 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.1 +4.2 From b3162eff56a0d9c1809549fa19f739031c158480 Mon Sep 17 00:00:00 2001 From: Julio Alorro Date: Thu, 14 Mar 2019 13:35:58 +0100 Subject: [PATCH 4/6] [Add] LayoutKit (10.1.1) --- LayoutKit/10.1.1/LayoutKit.podspec | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 LayoutKit/10.1.1/LayoutKit.podspec diff --git a/LayoutKit/10.1.1/LayoutKit.podspec b/LayoutKit/10.1.1/LayoutKit.podspec new file mode 100644 index 00000000..7b64dbfc --- /dev/null +++ b/LayoutKit/10.1.1/LayoutKit.podspec @@ -0,0 +1,44 @@ +Pod::Spec.new do |spec| + spec.name = 'LayoutKit' + spec.version = '10.1.1' + spec.license = { :type => 'Apache License, Version 2.0' } + spec.homepage = 'http://layoutkit.org' + spec.authors = 'LinkedIn' + spec.summary = 'LayoutKit is a fast view layout library for iOS, macOS, and tvOS.' + spec.source = { :git => 'https://github.com/hooliooo/LayoutKit.git', :tag => spec.version } + spec.source_files = 'Sources/**/*.swift' + spec.documentation_url = 'http://layoutkit.org' + + spec.ios.deployment_target = '8.0' + spec.ios.frameworks = 'Foundation', 'CoreGraphics', 'UIKit' + spec.ios.exclude_files = [ + 'Sources/AppKitSupport.swift', + 'Sources/ObjCSupport/**', + 'Sources/ObjCSupport/Internal/**' + ] + + spec.osx.deployment_target = '10.9' + spec.osx.frameworks = 'Foundation', 'CoreGraphics', 'AppKit' + spec.osx.exclude_files = [ + 'Sources/Internal/CGFloatExtension.swift', + 'Sources/Internal/TextViewDefaultFont.swift', + 'Sources/Internal/NSAttributedStringExtension.swift', + 'Sources/Layouts/ButtonLayout.swift', + 'Sources/Layouts/LabelLayout.swift', + 'Sources/Layouts/TextViewLayout.swift', + 'Sources/ObjCSupport/**', + 'Sources/ObjCSupport/Internal/**', + 'Sources/Text.swift', + 'Sources/UIKitSupport.swift', + 'Sources/Views/**' + ] + + spec.tvos.deployment_target = '9.0' + spec.tvos.frameworks = 'Foundation', 'CoreGraphics', 'UIKit' + spec.tvos.exclude_files = [ + 'Sources/AppKitSupport.swift', + 'Sources/ObjCSupport/**', + 'Sources/ObjCSupport/Internal/**' + ] + +end From 3817280f6bb86632bb301ee9de78b81754c5a2a8 Mon Sep 17 00:00:00 2001 From: Julio Alorro Date: Sat, 16 Mar 2019 19:45:54 +0100 Subject: [PATCH 5/6] incremented version and updated swift version to 4.2 --- LayoutKit.podspec | 2 +- LayoutKit.xcodeproj/project.pbxproj | 2 -- LayoutKit/10.1.1/LayoutKit.podspec | 44 ----------------------------- LayoutKitObjC.podspec | 5 ++-- Sources/Info.plist | 2 +- 5 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 LayoutKit/10.1.1/LayoutKit.podspec diff --git a/LayoutKit.podspec b/LayoutKit.podspec index 7b64dbfc..f1467b48 100644 --- a/LayoutKit.podspec +++ b/LayoutKit.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |spec| spec.homepage = 'http://layoutkit.org' spec.authors = 'LinkedIn' spec.summary = 'LayoutKit is a fast view layout library for iOS, macOS, and tvOS.' - spec.source = { :git => 'https://github.com/hooliooo/LayoutKit.git', :tag => spec.version } + spec.source = { :git => 'https://github.com/linkedin/LayoutKit.git', :tag => spec.version } spec.source_files = 'Sources/**/*.swift' spec.documentation_url = 'http://layoutkit.org' diff --git a/LayoutKit.xcodeproj/project.pbxproj b/LayoutKit.xcodeproj/project.pbxproj index d055ae50..3b96f0f5 100644 --- a/LayoutKit.xcodeproj/project.pbxproj +++ b/LayoutKit.xcodeproj/project.pbxproj @@ -474,7 +474,6 @@ 0BD5F8281DB43B4500108688 /* ButtonLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonLayout.swift; sourceTree = ""; }; 0BD5F82B1DB43F9B00108688 /* ButtonLayoutTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonLayoutTests.swift; sourceTree = ""; }; 0BDDF95A1E25ACCE008B0A6F /* ReloadableViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReloadableViewTests.swift; sourceTree = ""; }; - 142C451D223A7D83002360F5 /* LayoutKit.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = LayoutKit.podspec; sourceTree = ""; }; 37BEBEF3207C23B6002BD761 /* LOKAnimation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LOKAnimation.swift; sourceTree = ""; }; 37D9D58320BF8270001A5CDD /* LOKLayoutBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LOKLayoutBuilder.h; sourceTree = ""; }; 4468A31C1E46460B00341D07 /* NSAttributedStringExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSAttributedStringExtension.swift; sourceTree = ""; }; @@ -664,7 +663,6 @@ 0BCB75531D871FC40065E02A = { isa = PBXGroup; children = ( - 142C451D223A7D83002360F5 /* LayoutKit.podspec */, 0B7B269E1D919A9200CD1956 /* LayoutKit.playground */, 0BCB75611D8720110065E02A /* LayoutKit */, 0BCB756C1D8720110065E02A /* LayoutKitTests */, diff --git a/LayoutKit/10.1.1/LayoutKit.podspec b/LayoutKit/10.1.1/LayoutKit.podspec deleted file mode 100644 index 7b64dbfc..00000000 --- a/LayoutKit/10.1.1/LayoutKit.podspec +++ /dev/null @@ -1,44 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'LayoutKit' - spec.version = '10.1.1' - spec.license = { :type => 'Apache License, Version 2.0' } - spec.homepage = 'http://layoutkit.org' - spec.authors = 'LinkedIn' - spec.summary = 'LayoutKit is a fast view layout library for iOS, macOS, and tvOS.' - spec.source = { :git => 'https://github.com/hooliooo/LayoutKit.git', :tag => spec.version } - spec.source_files = 'Sources/**/*.swift' - spec.documentation_url = 'http://layoutkit.org' - - spec.ios.deployment_target = '8.0' - spec.ios.frameworks = 'Foundation', 'CoreGraphics', 'UIKit' - spec.ios.exclude_files = [ - 'Sources/AppKitSupport.swift', - 'Sources/ObjCSupport/**', - 'Sources/ObjCSupport/Internal/**' - ] - - spec.osx.deployment_target = '10.9' - spec.osx.frameworks = 'Foundation', 'CoreGraphics', 'AppKit' - spec.osx.exclude_files = [ - 'Sources/Internal/CGFloatExtension.swift', - 'Sources/Internal/TextViewDefaultFont.swift', - 'Sources/Internal/NSAttributedStringExtension.swift', - 'Sources/Layouts/ButtonLayout.swift', - 'Sources/Layouts/LabelLayout.swift', - 'Sources/Layouts/TextViewLayout.swift', - 'Sources/ObjCSupport/**', - 'Sources/ObjCSupport/Internal/**', - 'Sources/Text.swift', - 'Sources/UIKitSupport.swift', - 'Sources/Views/**' - ] - - spec.tvos.deployment_target = '9.0' - spec.tvos.frameworks = 'Foundation', 'CoreGraphics', 'UIKit' - spec.tvos.exclude_files = [ - 'Sources/AppKitSupport.swift', - 'Sources/ObjCSupport/**', - 'Sources/ObjCSupport/Internal/**' - ] - -end diff --git a/LayoutKitObjC.podspec b/LayoutKitObjC.podspec index c9f8284a..84bca230 100644 --- a/LayoutKitObjC.podspec +++ b/LayoutKitObjC.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'LayoutKitObjC' - spec.version = '10.1.0' + spec.version = '10.1.1' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'http://layoutkit.org' spec.authors = 'LinkedIn' @@ -45,8 +45,7 @@ Pod::Spec.new do |spec| # Excluded due to "'systemFontSize' is unavailable" 'Sources/ObjCSupport/Builders/LOKLabelLayoutBuilder.*', - 'Sources/ObjCSupport/LOKLabelLayout.swift' + 'Sources/ObjCSupport/LOKLabelLayout.swift' ] end - diff --git a/Sources/Info.plist b/Sources/Info.plist index 6f97bda2..8fb0c957 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 10.1.0 + 10.1.1 CFBundleSignature ???? CFBundleVersion From 13f3c37095b1694ed0e363bff29d1c0bc68fe730 Mon Sep 17 00:00:00 2001 From: Julio Alorro Date: Tue, 26 Mar 2019 10:04:12 +0100 Subject: [PATCH 6/6] Updated for Swift 5 --- LayoutKit.xcodeproj/project.pbxproj | 38 ++++++++++++++++--- .../xcschemes/ExampleLayouts-iOS.xcscheme | 2 +- .../xcschemes/LayoutKit-iOS.xcscheme | 2 +- .../xcschemes/LayoutKit-macOS.xcscheme | 2 +- .../xcschemes/LayoutKit-tvOS.xcscheme | 2 +- .../xcschemes/LayoutKitObjC-iOS.xcscheme | 2 +- .../xcschemes/LayoutKitSampleApp.xcscheme | 2 +- LayoutKitSampleApp/AppDelegate.swift | 2 +- .../Benchmarks/TableViewController.swift | 4 +- LayoutKitTests/LabelLayoutTests.swift | 6 +-- ...ViewLayoutAdapterCollectionViewTests.swift | 4 +- ...dableViewLayoutAdapterTableViewTests.swift | 12 +++--- LayoutKitTests/TextExtension.swift | 6 +-- LayoutKitTests/TextViewLayoutTests.swift | 4 +- Sources/ConfigurableLayout.swift | 2 +- Sources/UIKitSupport.swift | 2 + build.sh | 7 ++++ 17 files changed, 68 insertions(+), 31 deletions(-) diff --git a/LayoutKit.xcodeproj/project.pbxproj b/LayoutKit.xcodeproj/project.pbxproj index 3b96f0f5..959b85fd 100644 --- a/LayoutKit.xcodeproj/project.pbxproj +++ b/LayoutKit.xcodeproj/project.pbxproj @@ -1154,52 +1154,60 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; TargetAttributes = { 0B2D09AF1D8735E1007E487C = { CreatedOnToolsVersion = 8.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 0BCB755E1D8720110065E02A = { CreatedOnToolsVersion = 8.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 0BCB75671D8720110065E02A = { CreatedOnToolsVersion = 8.0; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 0BCB757B1D8721370065E02A = { CreatedOnToolsVersion = 8.0; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 0BCB75831D8721370065E02A = { CreatedOnToolsVersion = 8.0; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 0BCB75971D8722370065E02A = { CreatedOnToolsVersion = 8.0; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 0BCB759F1D8722370065E02A = { CreatedOnToolsVersion = 8.0; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 0BCB75B51D8723B30065E02A = { CreatedOnToolsVersion = 8.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 7EEA2AB5201D18F20077A088 = { CreatedOnToolsVersion = 9.2; ProvisioningStyle = Automatic; }; + 7EECD00E2053916C003DC4B1 = { + LastSwiftMigration = 1020; + }; }; }; buildConfigurationList = 0BCB75571D871FC40065E02A /* Build configuration list for PBXProject "LayoutKit" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -1728,6 +1736,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1775,6 +1784,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -1783,6 +1793,7 @@ 0BCB75581D871FC40065E02A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; @@ -1817,6 +1828,7 @@ 0BCB75591D871FC40065E02A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; @@ -1906,6 +1918,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1963,6 +1976,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -2021,6 +2035,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -2067,6 +2082,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -2128,6 +2144,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -2184,6 +2201,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; @@ -2241,6 +2259,7 @@ SDKROOT = appletvos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.2; }; name = Debug; @@ -2286,6 +2305,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.2; VALIDATE_PRODUCT = YES; }; @@ -2351,6 +2371,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -2408,6 +2429,7 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -2465,6 +2487,7 @@ SDKROOT = macosx; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -2512,6 +2535,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -2573,6 +2597,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -2629,6 +2654,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -2771,6 +2797,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -2828,6 +2855,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; diff --git a/LayoutKit.xcodeproj/xcshareddata/xcschemes/ExampleLayouts-iOS.xcscheme b/LayoutKit.xcodeproj/xcshareddata/xcschemes/ExampleLayouts-iOS.xcscheme index 53f5d6e0..62d0d4d4 100644 --- a/LayoutKit.xcodeproj/xcshareddata/xcschemes/ExampleLayouts-iOS.xcscheme +++ b/LayoutKit.xcodeproj/xcshareddata/xcschemes/ExampleLayouts-iOS.xcscheme @@ -1,6 +1,6 @@ Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { window = UIWindow(frame: UIScreen.main.bounds) window?.rootViewController = UINavigationController(rootViewController: MenuViewController()) window?.makeKeyAndVisible() diff --git a/LayoutKitSampleApp/Benchmarks/TableViewController.swift b/LayoutKitSampleApp/Benchmarks/TableViewController.swift index d486d0df..3ca041f9 100644 --- a/LayoutKitSampleApp/Benchmarks/TableViewController.swift +++ b/LayoutKitSampleApp/Benchmarks/TableViewController.swift @@ -28,7 +28,7 @@ class TableViewController: UITableViewController where init(data: [CellType.DataType]) { self.data = data - super.init(style: UITableViewStyle.grouped) + super.init(style: UITableView.Style.grouped) } required init?(coder aDecoder: NSCoder) { @@ -52,7 +52,7 @@ class TableViewController: UITableViewController where } override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - return UITableViewAutomaticDimension + return UITableView.automaticDimension } } diff --git a/LayoutKitTests/LabelLayoutTests.swift b/LayoutKitTests/LabelLayoutTests.swift index f7eed7c2..f1c20321 100644 --- a/LayoutKitTests/LabelLayoutTests.swift +++ b/LayoutKitTests/LabelLayoutTests.swift @@ -52,7 +52,7 @@ class LabelLayoutTests: XCTestCase { } func testAttributedLabel() { - let attributedText = NSAttributedString(string: "Hi", attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 42)]) + let attributedText = NSAttributedString(string: "Hi", attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 42)]) let font = UIFont.helvetica(size: 99) let arrangement = LabelLayout(attributedText: attributedText, font: font).arrangement() @@ -122,7 +122,7 @@ class LabelLayoutTests: XCTestCase { func testAttributedTextCustomFont() { #if !os(tvOS) // tvOS doesn't currently support custom fonts let font = UIFont(name: "Papyrus", size: 20)! - let attributes = [NSAttributedStringKey.font: font] + let attributes = [NSAttributedString.Key.font: font] let text = NSAttributedString(string: "Hello! 😄😄😄", attributes: attributes) let arrangement = LabelLayout(attributedText: text).arrangement() @@ -136,7 +136,7 @@ class LabelLayoutTests: XCTestCase { #if !os(tvOS) // tvOS doesn't currently support custom fonts let font = UIFont(name: "Papyrus", size: 20)! let text = NSMutableAttributedString(string: "Hello world! 😄😄😄") - text.addAttribute(NSAttributedStringKey.font, value: font, range: NSMakeRange(6, 6)) + text.addAttribute(NSAttributedString.Key.font, value: font, range: NSMakeRange(6, 6)) let arrangement = LabelLayout(attributedText: text).arrangement() let label = UILabel(attributedText: text) diff --git a/LayoutKitTests/ReloadableViewLayoutAdapterCollectionViewTests.swift b/LayoutKitTests/ReloadableViewLayoutAdapterCollectionViewTests.swift index dfcd83d7..3e57aa3b 100644 --- a/LayoutKitTests/ReloadableViewLayoutAdapterCollectionViewTests.swift +++ b/LayoutKitTests/ReloadableViewLayoutAdapterCollectionViewTests.swift @@ -110,11 +110,11 @@ private class TestCollectionView: LayoutAdapterCollectionView, TestableReloadabl } fileprivate func verifyHeader(_ section: Int, text: String?, frame: CGRect?, file: StaticString, line: UInt) { - verifySupplementaryView(UICollectionElementKindSectionHeader, section: section, text: text, frame: frame, file: file, line: line) + verifySupplementaryView(UICollectionView.elementKindSectionHeader, section: section, text: text, frame: frame, file: file, line: line) } fileprivate func verifyFooter(_ section: Int, text: String?, frame: CGRect?, file: StaticString, line: UInt) { - verifySupplementaryView(UICollectionElementKindSectionFooter, section: section, text: text, frame: frame, file: file, line: line) + verifySupplementaryView(UICollectionView.elementKindSectionFooter, section: section, text: text, frame: frame, file: file, line: line) } private func verifySupplementaryView(_ kind: String, section: Int, text: String?, frame: CGRect?, file: StaticString, line: UInt) { diff --git a/LayoutKitTests/ReloadableViewLayoutAdapterTableViewTests.swift b/LayoutKitTests/ReloadableViewLayoutAdapterTableViewTests.swift index b081c605..c11013e7 100644 --- a/LayoutKitTests/ReloadableViewLayoutAdapterTableViewTests.swift +++ b/LayoutKitTests/ReloadableViewLayoutAdapterTableViewTests.swift @@ -68,17 +68,17 @@ private class TestTableView: LayoutAdapterTableView, TestableReloadableView { reloadDataCount += 1 } - fileprivate override func insertRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation) { + fileprivate override func insertRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) { super.insertRows(at: indexPaths, with: animation) batchUpdates.insertItems.append(contentsOf: indexPaths) } - fileprivate override func deleteRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation) { + fileprivate override func deleteRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) { super.deleteRows(at: indexPaths, with: animation) batchUpdates.deleteItems.append(contentsOf: indexPaths) } - fileprivate override func reloadRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation) { + fileprivate override func reloadRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation) { super.reloadRows(at: indexPaths, with: animation) batchUpdates.reloadItems.append(contentsOf: indexPaths) } @@ -88,17 +88,17 @@ private class TestTableView: LayoutAdapterTableView, TestableReloadableView { batchUpdates.moveItems.append(ItemMove(from: indexPath, to: newIndexPath)) } - fileprivate override func insertSections(_ sections: IndexSet, with animation: UITableViewRowAnimation) { + fileprivate override func insertSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) { super.insertSections(sections, with: animation) batchUpdates.insertSections.formUnion(sections) } - fileprivate override func reloadSections(_ sections: IndexSet, with animation: UITableViewRowAnimation) { + fileprivate override func reloadSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) { super.reloadSections(sections, with: animation) batchUpdates.reloadSections.formUnion(sections) } - fileprivate override func deleteSections(_ sections: IndexSet, with animation: UITableViewRowAnimation) { + fileprivate override func deleteSections(_ sections: IndexSet, with animation: UITableView.RowAnimation) { super.deleteSections(sections, with: animation) batchUpdates.deleteSections.formUnion(sections) } diff --git a/LayoutKitTests/TextExtension.swift b/LayoutKitTests/TextExtension.swift index 699787f4..af6ce383 100644 --- a/LayoutKitTests/TextExtension.swift +++ b/LayoutKitTests/TextExtension.swift @@ -30,12 +30,12 @@ extension Text { .unattributed("Hello! 😄😄😄"), .attributed(NSAttributedString(string: "")), .attributed(NSAttributedString(string: " ")), - .attributed(NSAttributedString(string: "", attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 42)])), - .attributed(NSAttributedString(string: " ", attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 42)])), + .attributed(NSAttributedString(string: "", attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 42)])), + .attributed(NSAttributedString(string: " ", attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 42)])), .attributed(NSAttributedString(string: "Hi")), .attributed(NSAttributedString(string: "Hello world")), .attributed(NSAttributedString(string: "Hello! 😄😄😄")), - .attributed(NSAttributedString(string: "Hello! 😄😄😄", attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 42)])), + .attributed(NSAttributedString(string: "Hello! 😄😄😄", attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 42)])), ] let fontSizes = 0...20 diff --git a/LayoutKitTests/TextViewLayoutTests.swift b/LayoutKitTests/TextViewLayoutTests.swift index cf9db5a3..353767e9 100644 --- a/LayoutKitTests/TextViewLayoutTests.swift +++ b/LayoutKitTests/TextViewLayoutTests.swift @@ -67,10 +67,10 @@ class TextViewLayoutTests: XCTestCase { let textString = "Hello World\nHello World\nHello World\nHello World\nHello World" let attributedString1 = NSMutableAttributedString( string: textString, - attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 15)]) + attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 15)]) let attributedString2 = NSMutableAttributedString( string: textString, - attributes: [NSAttributedStringKey.font: UIFont.helvetica(size: 12)]) + attributes: [NSAttributedString.Key.font: UIFont.helvetica(size: 12)]) attributedString1.append(attributedString2) let attributedText = Text.attributed(attributedString1) diff --git a/Sources/ConfigurableLayout.swift b/Sources/ConfigurableLayout.swift index b205ea61..b1e2af0b 100644 --- a/Sources/ConfigurableLayout.swift +++ b/Sources/ConfigurableLayout.swift @@ -42,7 +42,7 @@ public protocol ConfigurableLayout: Layout { // Implement `configure(baseViewType:)` from `Layout`. public extension ConfigurableLayout { - public func configure(baseTypeView: View) { + func configure(baseTypeView: View) { guard let view = baseTypeView as? ConfigurableView else { assertionFailure("Expected baseTypeView \(baseTypeView) to be of type \(ConfigurableView.self) but it was of type \(type(of: baseTypeView))") return diff --git a/Sources/UIKitSupport.swift b/Sources/UIKitSupport.swift index a0d44664..0897c36e 100644 --- a/Sources/UIKitSupport.swift +++ b/Sources/UIKitSupport.swift @@ -39,6 +39,8 @@ extension UIView { return .leftToRight case .rightToLeft: return .rightToLeft + @unknown default: + return .leftToRight } } else { #if LAYOUTKIT_EXTENSION_DEFAULT_RIGHT_TO_LEFT diff --git a/build.sh b/build.sh index 33f3b85d..676c01ba 100755 --- a/build.sh +++ b/build.sh @@ -18,6 +18,7 @@ time xcodebuild clean test \ -destination 'platform=iOS Simulator,name=iPhone 6 Plus,OS=10.3.1' \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.3' \ -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=11.3' \ + -SWIFT_VERSION=5.0 \ OTHER_SWIFT_FLAGS='-Xfrontend -debug-time-function-bodies' \ | tee build.log \ | xcpretty && @@ -29,6 +30,7 @@ time xcodebuild clean test \ -scheme LayoutKit-macOS \ -sdk macosx10.13 \ -derivedDataPath $DERIVED_DATA \ + -SWIFT_VERSION=5.0 \ OTHER_SWIFT_FLAGS='-Xfrontend -debug-time-function-bodies' \ | tee build.log \ | xcpretty && @@ -42,6 +44,7 @@ time xcodebuild clean test \ -sdk appletvsimulator11.3 \ -derivedDataPath $DERIVED_DATA \ -destination 'platform=tvOS Simulator,name=Apple TV 1080p,OS=11.0' \ + -SWIFT_VERSION=5.0 \ OTHER_SWIFT_FLAGS='-Xfrontend -debug-time-function-bodies' \ | tee build.log \ | xcpretty && @@ -58,6 +61,7 @@ time xcodebuild clean build \ -destination 'platform=iOS Simulator,name=iPhone 6 Plus,OS=10.3.1' \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.3' \ -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=11.3' \ + -SWIFT_VERSION=5.0 \ OTHER_SWIFT_FLAGS='-Xfrontend -debug-time-function-bodies' \ | tee ../build.log \ | xcpretty && @@ -75,6 +79,7 @@ time xcodebuild clean build \ -sdk iphonesimulator11.3 \ -derivedDataPath $DERIVED_DATA \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.3' \ + -SWIFT_VERSION=5.0 \ OTHER_SWIFT_FLAGS='-Xfrontend -debug-time-function-bodies' \ | tee ../../../build.log \ | xcpretty && @@ -90,6 +95,7 @@ time xcodebuild clean build \ -scheme LayoutKit-macOS \ -sdk macosx10.13 \ -derivedDataPath $DERIVED_DATA \ + -SWIFT_VERSION=5.0 \ OTHER_SWIFT_FLAGS='-Xfrontend -debug-time-function-bodies' \ | tee ../../../build.log \ | xcpretty && @@ -106,6 +112,7 @@ time xcodebuild clean build \ -sdk appletvsimulator11.3 \ -derivedDataPath $DERIVED_DATA \ -destination 'platform=tvOS Simulator,name=Apple TV 1080p,OS=11.0' \ + -SWIFT_VERSION=5.0 \ OTHER_SWIFT_FLAGS='-Xfrontend -debug-time-function-bodies' \ | tee ../../../build.log \ | xcpretty &&