diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 3e10278..4b6c8f7 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -279,7 +279,8 @@ DDC9FD8D1981B4DD009612C7 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0600; + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = "SnapKit Team"; TargetAttributes = { EEBCC9D719CC627D0083B827 = { @@ -433,6 +434,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -506,6 +508,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = SnapKit; SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; @@ -526,6 +529,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = SnapKit; SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; @@ -537,12 +541,10 @@ EEBCC9EC19CC627E0083B827 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -550,12 +552,10 @@ EEBCC9ED19CC627E0083B827 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -578,6 +578,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = SnapKit; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -602,6 +603,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = SnapKit; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -615,13 +617,11 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(DEVELOPER_FRAMEWORKS_DIR)", - "$(inherited)", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; }; @@ -633,13 +633,11 @@ COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - FRAMEWORK_SEARCH_PATHS = ( - "$(DEVELOPER_FRAMEWORKS_DIR)", - "$(inherited)", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; }; diff --git a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit OSX.xcscheme b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit OSX.xcscheme index a6be18a..3ffad95 100644 --- a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit OSX.xcscheme +++ b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit OSX.xcscheme @@ -1,6 +1,6 @@ + + + + [LayoutConstraint] { - return self.installOnView(updateExisting: false) + return self.installOnViewUpdatingExisting(false) } internal override func uninstall() -> Void { @@ -191,10 +191,10 @@ internal class ConcreteConstraint: Constraint { self.priority = priority } - internal func installOnView(updateExisting: Bool = false) -> [LayoutConstraint] { + internal func installOnViewUpdatingExisting(updateExisting: Bool = false) -> [LayoutConstraint] { var installOnView: View? = nil if self.toItem.view != nil { - installOnView = closestCommonSuperviewBetween(self.fromItem.view, self.toItem.view) + installOnView = closestCommonSuperviewFromView(self.fromItem.view, toView: self.toItem.view) if installOnView == nil { NSException(name: "Cannot Install Constraint", reason: "No common superview between views", userInfo: nil).raise() return [] @@ -236,7 +236,7 @@ internal class ConcreteConstraint: Constraint { let layoutToAttribute = (layoutToAttributes.count > 0) ? layoutToAttributes[0] : layoutFromAttribute // get layout constant - var layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant) + let layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant) // get layout to var layoutTo: View? = self.toItem.view @@ -266,7 +266,7 @@ internal class ConcreteConstraint: Constraint { // special logic for updating if updateExisting { // get existing constraints for this view - let existingLayoutConstraints = reverse(layoutFrom!.snp_installedLayoutConstraints) + let existingLayoutConstraints = layoutFrom!.snp_installedLayoutConstraints.reverse() // array that will contain only new layout constraints to keep var newLayoutConstraintsToKeep = [LayoutConstraint]() @@ -330,7 +330,7 @@ internal class ConcreteConstraint: Constraint { // remove the constraints from the from item view if let fromView = self.fromItem.view { fromView.snp_installedLayoutConstraints = fromView.snp_installedLayoutConstraints.filter { - return !contains(installedLayoutConstraints, $0) + return !installedLayoutConstraints.contains($0) } } } @@ -432,11 +432,11 @@ private extension NSLayoutAttribute { } } -private func closestCommonSuperviewBetween(fromView: View?, toView: View?) -> View? { +private func closestCommonSuperviewFromView(fromView: View?, toView: View?) -> View? { var views = Set() var fromView = fromView var toView = toView - do { + repeat { if let view = toView { if views.contains(view) { return view diff --git a/Source/ConstraintMaker.swift b/Source/ConstraintMaker.swift index 746c49f..04214a0 100644 --- a/Source/ConstraintMaker.swift +++ b/Source/ConstraintMaker.swift @@ -137,48 +137,36 @@ public class ConstraintMaker { } internal class func makeConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) { - #if os(iOS) - view.setTranslatesAutoresizingMaskIntoConstraints(false) - #else view.translatesAutoresizingMaskIntoConstraints = false - #endif let maker = ConstraintMaker(view: view) closure(make: maker) let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint } for constraint in constraints { - constraint.installOnView(updateExisting: false) + constraint.installOnViewUpdatingExisting(false) } } internal class func remakeConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) { - #if os(iOS) - view.setTranslatesAutoresizingMaskIntoConstraints(false) - #else view.translatesAutoresizingMaskIntoConstraints = false - #endif let maker = ConstraintMaker(view: view) closure(make: maker) self.removeConstraints(view) let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint } for constraint in constraints { - constraint.installOnView(updateExisting: false) + constraint.installOnViewUpdatingExisting(false) } } internal class func updateConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) { - #if os(iOS) - view.setTranslatesAutoresizingMaskIntoConstraints(false) - #else view.translatesAutoresizingMaskIntoConstraints = false - #endif let maker = ConstraintMaker(view: view) closure(make: maker) let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint} for constraint in constraints { - constraint.installOnView(updateExisting: true) + constraint.installOnViewUpdatingExisting(true) } } diff --git a/Source/Debugging.swift b/Source/Debugging.swift index 8a96a74..b49b253 100644 --- a/Source/Debugging.swift +++ b/Source/Debugging.swift @@ -37,7 +37,7 @@ public extension View { return objc_getAssociatedObject(self, &labelKey) as? String } set { - objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy(OBJC_ASSOCIATION_COPY_NONATOMIC)) + objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC) } } @@ -53,7 +53,7 @@ public extension LayoutConstraint { return objc_getAssociatedObject(self, &labelKey) as? String } set { - objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy(OBJC_ASSOCIATION_COPY_NONATOMIC)) + objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC) } } diff --git a/Source/Info.plist b/Source/Info.plist index 9659480..d3de8ee 100644 --- a/Source/Info.plist +++ b/Source/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - io.snapkit.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Source/View+SnapKit.swift b/Source/View+SnapKit.swift index 5141879..0fc39a8 100644 --- a/Source/View+SnapKit.swift +++ b/Source/View+SnapKit.swift @@ -172,7 +172,7 @@ public extension View { return [] } set { - objc_setAssociatedObject(self, &installedLayoutConstraintsKey, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) + objc_setAssociatedObject(self, &installedLayoutConstraintsKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) } } } diff --git a/Tests/Info.plist b/Tests/Info.plist index e06ec80..ba72822 100644 --- a/Tests/Info.plist +++ b/Tests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - io.snapkit.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Tests/Tests.swift b/Tests/Tests.swift index c7d8c72..96bc368 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -2,7 +2,7 @@ import UIKit typealias View = UIView extension View { - var snp_constraints: [AnyObject] { return self.constraints() } + var snp_constraints: [AnyObject] { return self.constraints } } #else import AppKit