From ce89f87d08cbfedcf44dbd4cb950fc76c87d878c Mon Sep 17 00:00:00 2001 From: Mark Aufflick Date: Fri, 20 May 2016 17:57:29 +1000 Subject: [PATCH 1/5] Preliminary podspec --- SwiftAutoLayout.podspec | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 SwiftAutoLayout.podspec diff --git a/SwiftAutoLayout.podspec b/SwiftAutoLayout.podspec new file mode 100644 index 0000000..9c6d14c --- /dev/null +++ b/SwiftAutoLayout.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = "SwiftAutoLayout" + s.version = "1.0.0" + s.summary = "Tiny Swift SDL for Autolayout" + s.homepage = "https://github.com/indragiek/SwiftAutoLayout" + s.author = { "Indragie Karunatne" => "i@indragie.com" } + s.license = "MIT" + s.platform = :ios + s.ios.deployment_target = "8.0" + s.source = { :git => "https://github.com/indragiek/SwiftAutoLayout.git", :tag => "#{s.version}" } + s.source_files = "Sources/*.{swift}" + s.framework = "UIKit" +end From b9b7f71e11a052d7cf3478ca4aabf3ff48c9142a Mon Sep 17 00:00:00 2001 From: Mark Aufflick Date: Tue, 27 Sep 2016 16:22:21 +1000 Subject: [PATCH 2/5] Single change required for swift 2.3 compatibility --- Sources/SwiftAutoLayout.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftAutoLayout.swift b/Sources/SwiftAutoLayout.swift index a781a17..c2cb425 100644 --- a/Sources/SwiftAutoLayout.swift +++ b/Sources/SwiftAutoLayout.swift @@ -108,7 +108,7 @@ public extension LayoutRegion { } public extension View { - public var baseline: LayoutItem { return layoutItem(self, .Baseline) } + public var baseline: LayoutItem { return layoutItem(self, .LastBaseline) } @available(iOS 8.0, OSX 10.11, *) public var firstBaseline: LayoutItem { return layoutItem(self, .FirstBaseline) } From e2fbb14c3a57e4690963cf3d425674fa612fed30 Mon Sep 17 00:00:00 2001 From: Mark Aufflick Date: Wed, 26 Oct 2016 15:45:10 +1100 Subject: [PATCH 3/5] Added osx to podspec --- SwiftAutoLayout.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftAutoLayout.podspec b/SwiftAutoLayout.podspec index 9c6d14c..ca215fe 100644 --- a/SwiftAutoLayout.podspec +++ b/SwiftAutoLayout.podspec @@ -5,8 +5,8 @@ Pod::Spec.new do |s| s.homepage = "https://github.com/indragiek/SwiftAutoLayout" s.author = { "Indragie Karunatne" => "i@indragie.com" } s.license = "MIT" - s.platform = :ios s.ios.deployment_target = "8.0" + s.osx.deployment_target = "10.9" s.source = { :git => "https://github.com/indragiek/SwiftAutoLayout.git", :tag => "#{s.version}" } s.source_files = "Sources/*.{swift}" s.framework = "UIKit" From 3aaa377a7d0f407f9c49014d4ae67c3b31f7268a Mon Sep 17 00:00:00 2001 From: Mark Aufflick Date: Wed, 26 Oct 2016 16:31:21 +1100 Subject: [PATCH 4/5] Added osx to podspec --- SwiftAutoLayout.podspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SwiftAutoLayout.podspec b/SwiftAutoLayout.podspec index ca215fe..10f139c 100644 --- a/SwiftAutoLayout.podspec +++ b/SwiftAutoLayout.podspec @@ -9,5 +9,6 @@ Pod::Spec.new do |s| s.osx.deployment_target = "10.9" s.source = { :git => "https://github.com/indragiek/SwiftAutoLayout.git", :tag => "#{s.version}" } s.source_files = "Sources/*.{swift}" - s.framework = "UIKit" + s.ios.framework = "UIKit" + s.osx.framework = "Cocoa" end From ccc8529fe3277fd5ee256b19728677ba235fc062 Mon Sep 17 00:00:00 2001 From: Mark Aufflick Date: Thu, 27 Oct 2016 13:19:45 +1100 Subject: [PATCH 5/5] AppKit and UIKit have different optionality for firstItem in Swift 2.3 --- Sources/SwiftAutoLayout.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftAutoLayout.swift b/Sources/SwiftAutoLayout.swift index c2cb425..8857b40 100644 --- a/Sources/SwiftAutoLayout.swift +++ b/Sources/SwiftAutoLayout.swift @@ -149,7 +149,11 @@ public extension UIView { infix operator ~ { associativity left precedence 120 } public func ~(lhs: NSLayoutConstraint, rhs: LayoutPriority) -> NSLayoutConstraint { - let newConstraint = NSLayoutConstraint(item: lhs.firstItem, attribute: lhs.firstAttribute, relatedBy: lhs.relation, toItem: lhs.secondItem, attribute: lhs.secondAttribute, multiplier: lhs.multiplier, constant: lhs.constant) + #if os(OSX) + let newConstraint = NSLayoutConstraint(item: lhs.firstItem!, attribute: lhs.firstAttribute, relatedBy: lhs.relation, toItem: lhs.secondItem, attribute: lhs.secondAttribute, multiplier: lhs.multiplier, constant: lhs.constant) + #else + let newConstraint = NSLayoutConstraint(item: lhs.firstItem, attribute: lhs.firstAttribute, relatedBy: lhs.relation, toItem: lhs.secondItem, attribute: lhs.secondAttribute, multiplier: lhs.multiplier, constant: lhs.constant) + #endif newConstraint.priority = rhs return newConstraint }