From cfa5e8cb5b38c2cb38bb8bc373a07dd5ae04eddb Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 11 Oct 2016 23:17:32 +1300 Subject: [PATCH] Fix up iOS 9 / OSX 10.11 availability on Layout Guides --- SnapKit.xcodeproj/project.pbxproj | 8 ++++---- ...sions.swift => ConstraintLayoutGuide+Extensions.swift} | 2 +- Source/ConstraintLayoutGuide.swift | 3 ++- Source/ConstraintLayoutGuideDSL.swift | 2 +- Source/LayoutConstraintItem.swift | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) rename Source/{UILayoutGuide+Extensions.swift => ConstraintLayoutGuide+Extensions.swift} (97%) diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 736d018..0fcb244 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -38,7 +38,7 @@ EECDB3931AC0CB52006BBC11 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; }; EEF68F9E1D78492400980C26 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */; }; EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */; }; - EEF68FB01D784FB100980C26 /* UILayoutGuide+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FAF1D784FB100980C26 /* UILayoutGuide+Extensions.swift */; }; + EEF68FB01D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */; }; EEF68FB41D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */; }; EEF68FBC1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */; }; EEF68FC01D7865AA00980C26 /* ConstraintLayoutSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FBF1D7865AA00980C26 /* ConstraintLayoutSupport.swift */; }; @@ -82,7 +82,7 @@ EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuideDSL.swift; sourceTree = ""; }; EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDSL.swift; sourceTree = ""; }; - EEF68FAF1D784FB100980C26 /* UILayoutGuide+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILayoutGuide+Extensions.swift"; sourceTree = ""; }; + EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintLayoutGuide+Extensions.swift"; sourceTree = ""; }; EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILayoutSupport+Extensions.swift"; sourceTree = ""; }; EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuide.swift; sourceTree = ""; }; EEF68FBF1D7865AA00980C26 /* ConstraintLayoutSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutSupport.swift; sourceTree = ""; }; @@ -129,7 +129,7 @@ isa = PBXGroup; children = ( EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */, - EEF68FAF1D784FB100980C26 /* UILayoutGuide+Extensions.swift */, + EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */, EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */, ); name = Extensions; @@ -371,7 +371,7 @@ EE235F881C5785C600C08960 /* ConstraintItem.swift in Sources */, EE235F9A1C5785CE00C08960 /* ConstraintPriorityTarget.swift in Sources */, EEF68FC01D7865AA00980C26 /* ConstraintLayoutSupport.swift in Sources */, - EEF68FB01D784FB100980C26 /* UILayoutGuide+Extensions.swift in Sources */, + EEF68FB01D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift in Sources */, EE235F761C5785C600C08960 /* ConstraintConfig.swift in Sources */, EE235F6D1C5785C600C08960 /* Constraint.swift in Sources */, EE235F791C5785C600C08960 /* ConstraintView.swift in Sources */, diff --git a/Source/UILayoutGuide+Extensions.swift b/Source/ConstraintLayoutGuide+Extensions.swift similarity index 97% rename from Source/UILayoutGuide+Extensions.swift rename to Source/ConstraintLayoutGuide+Extensions.swift index cd89d8a..c2d9e9d 100644 --- a/Source/UILayoutGuide+Extensions.swift +++ b/Source/ConstraintLayoutGuide+Extensions.swift @@ -26,7 +26,7 @@ #endif -@available(iOS 9.0, *) +@available(iOS 9.0, OSX 10.11, *) public extension ConstraintLayoutGuide { public var snp: ConstraintLayoutGuideDSL { diff --git a/Source/ConstraintLayoutGuide.swift b/Source/ConstraintLayoutGuide.swift index f6eba82..e3e50c8 100644 --- a/Source/ConstraintLayoutGuide.swift +++ b/Source/ConstraintLayoutGuide.swift @@ -32,5 +32,6 @@ @available(iOS 9.0, *) public typealias ConstraintLayoutGuide = UILayoutGuide #else - public class ConstraintLayoutGuide {} + @available(OSX 10.11, *) + public typealias ConstraintLayoutGuide = NSLayoutGuide #endif diff --git a/Source/ConstraintLayoutGuideDSL.swift b/Source/ConstraintLayoutGuideDSL.swift index d5b1949..0007819 100644 --- a/Source/ConstraintLayoutGuideDSL.swift +++ b/Source/ConstraintLayoutGuideDSL.swift @@ -28,7 +28,7 @@ #endif -@available(iOS 9.0, *) +@available(iOS 9.0, OSX 10.11, *) public struct ConstraintLayoutGuideDSL: ConstraintAttributesDSL { @discardableResult diff --git a/Source/LayoutConstraintItem.swift b/Source/LayoutConstraintItem.swift index fd7f213..9260e76 100644 --- a/Source/LayoutConstraintItem.swift +++ b/Source/LayoutConstraintItem.swift @@ -31,7 +31,7 @@ public protocol LayoutConstraintItem: class { } -@available(iOS 9.0, *) +@available(iOS 9.0, OSX 10.11, *) extension ConstraintLayoutGuide : LayoutConstraintItem { } @@ -52,7 +52,7 @@ extension LayoutConstraintItem { return view.superview } - if #available(iOS 9.0, *), let guide = self as? ConstraintLayoutGuide { + if #available(iOS 9.0, OSX 10.11, *), let guide = self as? ConstraintLayoutGuide { return guide.owningView }