mirror of https://github.com/SnapKit/SnapKit
Migrated to latest Swift 3.0 syntax and latest macOS Cocoa API
This commit is contained in:
parent
8355410d92
commit
d00444d7d1
|
@ -490,7 +490,7 @@
|
|||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0720;
|
||||
LastUpgradeCheck = 0700;
|
||||
LastUpgradeCheck = 0800;
|
||||
ORGANIZATIONNAME = "SnapKit Team";
|
||||
TargetAttributes = {
|
||||
537DCE911C35CC8800B5B899 = {
|
||||
|
@ -771,6 +771,7 @@
|
|||
PRODUCT_NAME = SnapKit;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
|
@ -804,6 +805,7 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = appletvos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.1;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -831,6 +833,7 @@
|
|||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
|
@ -875,6 +878,7 @@
|
|||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
|
@ -931,6 +935,7 @@
|
|||
PRODUCT_NAME = SnapKit;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
|
@ -957,6 +962,7 @@
|
|||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -1012,6 +1018,7 @@
|
|||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
|
@ -1044,6 +1051,7 @@
|
|||
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
@ -37,10 +37,10 @@
|
|||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
|
@ -66,11 +66,11 @@
|
|||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
|
@ -88,10 +88,10 @@
|
|||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
@ -37,10 +37,10 @@
|
|||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
|
@ -66,11 +66,11 @@
|
|||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
|
@ -88,10 +88,10 @@
|
|||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0720"
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -240,7 +240,7 @@ public class Constraint {
|
|||
|
||||
internal func activateIfNeeded() {
|
||||
guard self.installInfo != nil else {
|
||||
self.installIfNeeded()
|
||||
let _ = self.installIfNeeded()
|
||||
return
|
||||
}
|
||||
#if SNAPKIT_DEPLOYMENT_LEGACY
|
||||
|
|
|
@ -86,11 +86,11 @@ extension ConstraintConstantTarget {
|
|||
}
|
||||
#else
|
||||
switch layoutAttribute {
|
||||
case .Left, .Right, .Leading, .Trailing, .CenterX:
|
||||
case .left, .right, .leading, .trailing, .centerX:
|
||||
return value.x
|
||||
case .Top, .Bottom, .CenterY, .Baseline, .FirstBaseline:
|
||||
case .top, .bottom, .centerY, .lastBaseline, .firstBaseline:
|
||||
return value.y
|
||||
case .Width, .Height, .NotAnAttribute:
|
||||
case .width, .height, .notAnAttribute:
|
||||
return 0.0
|
||||
}
|
||||
#endif
|
||||
|
@ -120,23 +120,23 @@ extension ConstraintConstantTarget {
|
|||
}
|
||||
#else
|
||||
switch layoutAttribute {
|
||||
case .Left, .CenterX:
|
||||
case .left, .centerX:
|
||||
return value.left
|
||||
case .Top, .CenterY, .Baseline, .FirstBaseline:
|
||||
case .top, .centerY, .lastBaseline, .firstBaseline:
|
||||
return value.top
|
||||
case .Right:
|
||||
case .right:
|
||||
return value.right
|
||||
case .Bottom:
|
||||
case .bottom:
|
||||
return value.bottom
|
||||
case .Leading:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .LeftToRight) ? value.left : -value.right
|
||||
case .Trailing:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .LeftToRight) ? value.right : -value.left
|
||||
case .Width:
|
||||
case .leading:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : -value.right
|
||||
case .trailing:
|
||||
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.right : -value.left
|
||||
case .width:
|
||||
return -value.left + value.right
|
||||
case .Height:
|
||||
case .height:
|
||||
return -value.top + value.bottom
|
||||
case .NotAnAttribute:
|
||||
case .notAnAttribute:
|
||||
return 0.0
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,5 +31,5 @@
|
|||
#if os(iOS) || os(tvOS)
|
||||
public typealias ConstraintInsets = UIEdgeInsets
|
||||
#else
|
||||
public typealias ConstraintInsets = NSEdgeInsets
|
||||
public typealias ConstraintInsets = EdgeInsets
|
||||
#endif
|
||||
|
|
|
@ -135,7 +135,7 @@ public class ConstraintMaker {
|
|||
return ConstraintMakerExtendable(description)
|
||||
}
|
||||
|
||||
internal static func prepareConstraints(view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
internal static func prepareConstraints(view: ConstraintView, closure: @noescape(make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
let maker = ConstraintMaker(view: view)
|
||||
closure(make: maker)
|
||||
let constraints = maker.descriptions
|
||||
|
@ -145,7 +145,7 @@ public class ConstraintMaker {
|
|||
return constraints
|
||||
}
|
||||
|
||||
internal static func makeConstraints(view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
internal static func makeConstraints(view: ConstraintView, closure: @noescape(make: ConstraintMaker) -> Void) {
|
||||
let maker = ConstraintMaker(view: view)
|
||||
closure(make: maker)
|
||||
let constraints = maker.descriptions
|
||||
|
@ -153,16 +153,16 @@ public class ConstraintMaker {
|
|||
.filter { $0 != nil }
|
||||
.map { $0! }
|
||||
for constraint in constraints {
|
||||
constraint.installIfNeeded()
|
||||
let _ = constraint.installIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
internal static func remakeConstraints(view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
internal static func remakeConstraints(view: ConstraintView, closure: @noescape(make: ConstraintMaker) -> Void) {
|
||||
self.removeConstraints(view: view)
|
||||
self.makeConstraints(view: view, closure: closure)
|
||||
}
|
||||
|
||||
internal static func updateConstraints(view: ConstraintView, @noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
internal static func updateConstraints(view: ConstraintView, closure: @noescape(make: ConstraintMaker) -> Void) {
|
||||
let maker = ConstraintMaker(view: view)
|
||||
closure(make: maker)
|
||||
let constraints = maker.descriptions
|
||||
|
@ -170,7 +170,7 @@ public class ConstraintMaker {
|
|||
.filter { $0 != nil }
|
||||
.map { $0! }
|
||||
for constraint in constraints {
|
||||
constraint.installIfNeeded(updateExisting: true)
|
||||
let _ = constraint.installIfNeeded(updateExisting: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,23 +106,23 @@ public extension ConstraintView {
|
|||
public var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins }
|
||||
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
public func snp_prepareConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
return self.snp.prepareConstraints(closure: closure)
|
||||
public func snp_prepareConstraints(_ closure: @noescape(make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
return self.snp.prepareConstraints(closure)
|
||||
}
|
||||
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
public func snp_makeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
self.snp.makeConstraints(closure: closure)
|
||||
public func snp_makeConstraints(_ closure: @noescape(make: ConstraintMaker) -> Void) {
|
||||
self.snp.makeConstraints(closure)
|
||||
}
|
||||
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
public func snp_remakeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
self.snp.remakeConstraints(closure: closure)
|
||||
public func snp_remakeConstraints(_ closure: @noescape(make: ConstraintMaker) -> Void) {
|
||||
self.snp.remakeConstraints(closure)
|
||||
}
|
||||
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
public func snp_updateConstraints(@noescape closure: (make: ConstraintMaker) -> Void) {
|
||||
self.snp.updateConstraints(closure: closure)
|
||||
public func snp_updateConstraints(_ closure: @noescape(make: ConstraintMaker) -> Void) {
|
||||
self.snp.updateConstraints(closure)
|
||||
}
|
||||
|
||||
@available(iOS, deprecated:0.30.0, message:"Please use newer snp.* syntax.")
|
||||
|
|
|
@ -141,19 +141,19 @@ public struct ConstraintViewDSL {
|
|||
return ConstraintItem(target: self.view, attributes: ConstraintAttributes.CenterWithinMargins)
|
||||
}
|
||||
|
||||
public func prepareConstraints(closure: @noescape (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
public func prepareConstraints(_ closure: @noescape (make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||
return ConstraintMaker.prepareConstraints(view: self.view, closure: closure)
|
||||
}
|
||||
|
||||
public func makeConstraints(closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||
public func makeConstraints(_ closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||
ConstraintMaker.makeConstraints(view: self.view, closure: closure)
|
||||
}
|
||||
|
||||
public func remakeConstraints(closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||
public func remakeConstraints(_ closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||
ConstraintMaker.remakeConstraints(view: self.view, closure: closure)
|
||||
}
|
||||
|
||||
public func updateConstraints(closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||
public func updateConstraints(_ closure: @noescape (make: ConstraintMaker) -> Void) {
|
||||
ConstraintMaker.updateConstraints(view: self.view, closure: closure)
|
||||
}
|
||||
|
||||
|
|
|
@ -34,14 +34,17 @@ public extension LayoutConstraint {
|
|||
|
||||
description += descriptionForObject(self)
|
||||
|
||||
description += " \(descriptionForObject(self.firstItem))"
|
||||
if let firstItem = conditionalOptional(from: self.firstItem) {
|
||||
description += " \(descriptionForObject(firstItem))"
|
||||
}
|
||||
|
||||
if self.firstAttribute != .notAnAttribute {
|
||||
description += ".\(descriptionForAttribute(self.firstAttribute))"
|
||||
}
|
||||
|
||||
description += " \(descriptionForRelation(self.relation))"
|
||||
|
||||
if let secondItem: AnyObject = self.secondItem {
|
||||
if let secondItem = self.secondItem {
|
||||
description += " \(descriptionForObject(secondItem))"
|
||||
}
|
||||
|
||||
|
@ -96,7 +99,7 @@ private func descriptionForAttribute(_ attribute: NSLayoutAttribute) -> String {
|
|||
case .height: return "height"
|
||||
case .centerX: return "centerX"
|
||||
case .centerY: return "centerY"
|
||||
case .lastBaseline: return "baseline"
|
||||
case .lastBaseline: return "lastBaseline"
|
||||
case .firstBaseline: return "firstBaseline"
|
||||
case .topMargin: return "topMargin"
|
||||
case .leftMargin: return "leftMargin"
|
||||
|
@ -109,23 +112,31 @@ private func descriptionForAttribute(_ attribute: NSLayoutAttribute) -> String {
|
|||
}
|
||||
#else
|
||||
switch attribute {
|
||||
case .NotAnAttribute: return "notAnAttribute"
|
||||
case .Top: return "top"
|
||||
case .Left: return "left"
|
||||
case .Bottom: return "bottom"
|
||||
case .Right: return "right"
|
||||
case .Leading: return "leading"
|
||||
case .Trailing: return "trailing"
|
||||
case .Width: return "width"
|
||||
case .Height: return "height"
|
||||
case .CenterX: return "centerX"
|
||||
case .CenterY: return "centerY"
|
||||
case .Baseline: return "baseline"
|
||||
default: return "default"
|
||||
case .notAnAttribute: return "notAnAttribute"
|
||||
case .top: return "top"
|
||||
case .left: return "left"
|
||||
case .bottom: return "bottom"
|
||||
case .right: return "right"
|
||||
case .leading: return "leading"
|
||||
case .trailing: return "trailing"
|
||||
case .width: return "width"
|
||||
case .height: return "height"
|
||||
case .centerX: return "centerX"
|
||||
case .centerY: return "centerY"
|
||||
case .lastBaseline: return "lastBaseline"
|
||||
case .firstBaseline: return "firstBaseline"
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private func conditionalOptional<T>(from object: Optional<T>) -> Optional<T> {
|
||||
return object
|
||||
}
|
||||
|
||||
private func conditionalOptional<T>(from object: T) -> Optional<T> {
|
||||
return Optional.some(object)
|
||||
}
|
||||
|
||||
private func descriptionForObject(_ object: AnyObject) -> String {
|
||||
let pointerDescription = NSString(format: "%p", UInt(ObjectIdentifier(object)))
|
||||
var desc = ""
|
||||
|
|
Loading…
Reference in New Issue