Feature/release 5.6 (#746)

* Add support for UILayoutPriority as priority target. (#466)

* Add support for UILayoutPriority as priority target.

* Fixed for tvOS

* Add update(priority: ConstraintPriority) method (#467)

* Add update(priority: ConstraintPriority) method

* Fix copy-paste error

* Add Swift Package Manager support (#501)

* Swift4.2 (#516)

* make ConstraintAttributes conform to ExpressibleByIntegerLiteral (#520)

* Adds 'constraint.isActive = bool' to Constraint (#496)

* delegate identical 'constraint creation' code to 'prepareConstraints'

* adds 'set(isActivated:)' method to call appropriate 'activate/deactivate' based on bool

cleans up about 30 lines of

    if foo { activate }
    else { deactivate }

code in my app

* instead of 'set(isActivated:)', use 'isActive = value'

* Add swift version to podspec

* Update podspec

* Update podspec

* Update project to get rid of Migration Warning (#547)

* Update Swift Language version to 4.2 under build settings (#551)

* Update swift language version to 4.2 in build settings

* Update podspec

* Remove Swift Version file

* Remove Package.swift, SnapKit is not SwiftPM compatible anyways

* Update Podspec

* Update version in Podspec

* Support swift 5.0 (#570)

* Update swift version 5.0

* Remove needless access control

* Fix misused "Available" annotations

* Support @unknown default

* Support swift 5.0 in test code

* Update podspec

* Update travis CI

* Code review by @freak4pc

* Add constraint for Swift version

* Fix build failed

* [EXC_BAD_ACCESS] Update LayoutConstraint == operator to support iOS 10 and higher changes (#574)

* @sashabelonogov Update LayoutConstraint == operator to support iOS 10 and higher changes

* Simplify return statement of the LayoutConstraint == operator

* Fix incorrect behavior of inset with center and baseline anchors (#569)

* Fix insets adjusting center attributes incorrectly

* Fix insets adjusting baseline attributes incorrectly

* Add back Package.swift for SwiftPM compatibility (#559)

reverts 477fffae4c

* Update podspec

* Update min target versions

* Update min target versions

* Update README.md

* Update README.md

* Revert "[EXC_BAD_ACCESS] Update LayoutConstraint == operator to support iOS 10 and higher changes (#574)" (#593)

This reverts commit bc2b0b9332.

* Update Podspec

* Bump min version requirements

* Fix layout constraint comparison

* Fix equality check for iOS

* Adds support for NSDirectionalEdgeInsets as an inset constant (#594)

* Make ConstraintViewDSL content priorities nonmutating (#586)

* Adds two new compositions – DirectionalEdges and DirectionalMargins (#595)

* WIP

* Add directional margins

* Whitespace

* Add Playground Sample (#608)

* added updates to Package.swift so it can be imported with Xcode 11 (#615)

* Revert #574

* Update Podspec

* Add background color to quick start box in README.md (#619)

* add-dimensional-edges: add ConstraintItems horizontalEdges, verticalEdges, directionalHorizontalEdges and directionalVerticalEdges as convenience items to express left+right, top+bottom or leading+trailing (#637)

* Update deprecations to allow Xcode to auto-fixup. (#634)

* Migrate to Xcode 11 and updated travis.yml (#629)

* Migrate to Xcode 11 and updated travis.yml

* Travis to support Xcode 11

* project.pbxproj: Update to recommended settings. (#627)

* Add test assert to unit test testCanSetLabel. (#625)

* Add back support for OS X 10.11 (#645)

* Use << for ConstraintAttributes options (#659)

* Use << for ConstraintAttributes options

* iPhone 6s is not supported by the latest Xcode

* Add method getting constraint with closure to ConstraintMakerRelatable (#663)

* add ConstraintMakerRelatable extension

* fix fatalError message

Co-authored-by: Jimi <jimi-hpcnt@hpcnt.com>

* Xcode 12 and SwiftPM enhancements

* Update README to include SPM installation notes (#673)

* Fix typo

* Remove duplicate file

* xcodeproject configuration enhancement for localization (#584)

Co-authored-by: AmrAngry <c_amr.elghadban@smartdubai.ae>

* Updates to project files

* Dynamic Product (#710)

This PR adds a dynamic product to SnapKit.
Having a dynamic product is important in modular project structures; multiple packages may be using SnapKit, and this allows that support without the end-user have to wrap SnapKit in their own package that exposes it and using that package in lieu of SnapKit.

* Fix warning about `class` (#714)

* Added Example-iOS.xcdodeproj and fixed examples (#707)

* Update README.md, add missing Migration Guides section (#721)

* Make ConstraintMaker.item public (#693)

* Typo source directory in Podspec (#738)

Source directory has been renamed in 18608ead65

* Release 5.6

* Update urls in readme
* Update podspec version

Co-authored-by: Benjamin Chrobot <benjamin.blair.chrobot@gmail.com>
Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
Co-authored-by: Mauro Vime Castillo <mvimeapps@gmail.com>
Co-authored-by: o( ̄へ ̄)o <guzhenhuaGitHub@users.noreply.github.com>
Co-authored-by: Colin T.A. Gray <colinta@gmail.com>
Co-authored-by: Shai Mishali <freak4pc@gmail.com>
Co-authored-by: Ibrahim Koteish <ikteish@yahoo.com>
Co-authored-by: Jungwon An <kawoou@kawoou.kr>
Co-authored-by: Alexander Belonogov <sashabelonogov@gmail.com>
Co-authored-by: Christian Schnorr <christian.schnorr@me.com>
Co-authored-by: Josh Converse <josh.converse@gmail.com>
Co-authored-by: Vitalii Budnik <nekrich@users.noreply.github.com>
Co-authored-by: Shiva Huang <shiva.tw@gmail.com>
Co-authored-by: Max Cobb <5754073+maxxfrazer@users.noreply.github.com>
Co-authored-by: Liam Elmore <32336260+iosmo@users.noreply.github.com>
Co-authored-by: Sven Driemecker <sven.dr@gmx.de>
Co-authored-by: Alex Simpson <alexandersimpson94@gmail.com>
Co-authored-by: pushp1989 <54930194+pushp1989@users.noreply.github.com>
Co-authored-by: Ben Yohay <ben@lightricks.com>
Co-authored-by: Natascha Fadeeva <nataschafadeeva@aol.de>
Co-authored-by: Wang, Chi <patr0nus@users.noreply.github.com>
Co-authored-by: Roman Podymov <podymfrombryansk@yandex.ru>
Co-authored-by: wotjd <wotjd971102@gmail.com>
Co-authored-by: Jimi <jimi-hpcnt@hpcnt.com>
Co-authored-by: Samuel Eshun <samueleshun15@gmail.com>
Co-authored-by: Amr Elghadban <amr.elghadban@gmail.com>
Co-authored-by: AmrAngry <c_amr.elghadban@smartdubai.ae>
Co-authored-by: Hesham Salman <iron-ham@github.com>
Co-authored-by: Mr. Ming <minglq.9@gmail.com>
Co-authored-by: Teameh <tiemevanveen@hotmail.com>
Co-authored-by: Josip Rezić <josip.rezic@hotmail.com>
Co-authored-by: Rhett Tuan <devindwan@gmail.com>
Co-authored-by: Damien Debin <ddebin@users.noreply.github.com>
Co-authored-by: Robert Payne <robertjpayne@Roberts-MacBook-Pro.local>
This commit is contained in:
Robert Payne 2022-04-13 16:06:06 +12:00 committed by GitHub
parent d4cb974b3e
commit 851bbf8dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 1429 additions and 353 deletions

2
.gitignore vendored
View File

@ -1,3 +1,4 @@
.build/
project.xcworkspace project.xcworkspace
xcuserdata xcuserdata
Examples/ Examples/
@ -5,3 +6,4 @@ Examples/
Gemfile Gemfile
Gemfile.lock Gemfile.lock
*.sketch *.sketch
.swiftpm

View File

@ -1 +0,0 @@
4.0

View File

@ -1,10 +1,10 @@
language: objective-c language: objective-c
osx_image: xcode9 osx_image: xcode11
env: env:
- ACTION=test PLATFORM=Mac DESTINATION='platform=OS X' - ACTION=test PLATFORM=Mac DESTINATION='platform=macOS'
- ACTION=test PLATFORM=iOS DESTINATION='platform=iOS Simulator,name=iPhone 6S' - ACTION=test PLATFORM=iOS DESTINATION='platform=iOS Simulator,name=iPhone 8'
- ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 1080p' - ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 4K (at 1080p)'
script: script:
- set -o pipefail && xcodebuild -scheme SnapKit -destination "$DESTINATION" $ACTION | xcpretty - set -o pipefail && xcodebuild -scheme SnapKit -destination "$DESTINATION" $ACTION | xcpretty

View File

@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds) self.window = UIWindow(frame: UIScreen.main.bounds)
@ -27,4 +27,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true return true
} }
} }

View File

@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -2,37 +2,52 @@
"images" : [ "images" : [
{ {
"idiom" : "iphone", "idiom" : "iphone",
"size" : "29x29", "scale" : "2x",
"scale" : "2x" "size" : "20x20"
}, },
{ {
"idiom" : "iphone", "idiom" : "iphone",
"size" : "29x29", "scale" : "3x",
"scale" : "3x" "size" : "20x20"
}, },
{ {
"idiom" : "iphone", "idiom" : "iphone",
"size" : "40x40", "scale" : "2x",
"scale" : "2x" "size" : "29x29"
}, },
{ {
"idiom" : "iphone", "idiom" : "iphone",
"size" : "40x40", "scale" : "3x",
"scale" : "3x" "size" : "29x29"
}, },
{ {
"idiom" : "iphone", "idiom" : "iphone",
"size" : "60x60", "scale" : "2x",
"scale" : "2x" "size" : "40x40"
}, },
{ {
"idiom" : "iphone", "idiom" : "iphone",
"size" : "60x60", "scale" : "3x",
"scale" : "3x" "size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
} }
], ],
"info" : { "info" : {
"version" : 1, "author" : "xcode",
"author" : "xcode" "version" : 1
} }
} }

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,360 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objects = {
/* Begin PBXBuildFile section */
440B451E25D8696C00334F54 /* ListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440B451B25D8696C00334F54 /* ListViewController.swift */; };
440B452125D869A700334F54 /* BasicUIScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440B451F25D869A700334F54 /* BasicUIScrollViewController.swift */; };
440B452225D869A700334F54 /* SimpleLayoutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440B452025D869A700334F54 /* SimpleLayoutViewController.swift */; };
440B452B25D86C0100334F54 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 440B452A25D86C0100334F54 /* SnapKit */; };
44477D7225D86845009F5E40 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44477D7125D86845009F5E40 /* AppDelegate.swift */; };
44477D7B25D86846009F5E40 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 44477D7A25D86846009F5E40 /* Assets.xcassets */; };
44477D7E25D86846009F5E40 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 44477D7C25D86846009F5E40 /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
440B451B25D8696C00334F54 /* ListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListViewController.swift; sourceTree = "<group>"; };
440B451F25D869A700334F54 /* BasicUIScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BasicUIScrollViewController.swift; path = demos/BasicUIScrollViewController.swift; sourceTree = "<group>"; };
440B452025D869A700334F54 /* SimpleLayoutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SimpleLayoutViewController.swift; path = demos/SimpleLayoutViewController.swift; sourceTree = "<group>"; };
440B452925D86BF200334F54 /* SnapKit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SnapKit; path = ..; sourceTree = "<group>"; };
44477D6E25D86845009F5E40 /* Example-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
44477D7125D86845009F5E40 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
44477D7A25D86846009F5E40 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
44477D7D25D86846009F5E40 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
44477D7F25D86846009F5E40 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
44477D6B25D86845009F5E40 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
440B452B25D86C0100334F54 /* SnapKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
440B452725D86BDF00334F54 /* Frameworks */ = {
isa = PBXGroup;
children = (
440B452925D86BF200334F54 /* SnapKit */,
);
name = Frameworks;
sourceTree = "<group>";
};
44477D6525D86845009F5E40 = {
isa = PBXGroup;
children = (
44477D7025D86845009F5E40 /* Example-iOS */,
44477D6F25D86845009F5E40 /* Products */,
440B452725D86BDF00334F54 /* Frameworks */,
);
sourceTree = "<group>";
};
44477D6F25D86845009F5E40 /* Products */ = {
isa = PBXGroup;
children = (
44477D6E25D86845009F5E40 /* Example-iOS.app */,
);
name = Products;
sourceTree = "<group>";
};
44477D7025D86845009F5E40 /* Example-iOS */ = {
isa = PBXGroup;
children = (
44477D7C25D86846009F5E40 /* LaunchScreen.storyboard */,
44477D7A25D86846009F5E40 /* Assets.xcassets */,
44477D7F25D86846009F5E40 /* Info.plist */,
44477D7125D86845009F5E40 /* AppDelegate.swift */,
440B451B25D8696C00334F54 /* ListViewController.swift */,
440B451F25D869A700334F54 /* BasicUIScrollViewController.swift */,
440B452025D869A700334F54 /* SimpleLayoutViewController.swift */,
);
name = "Example-iOS";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
44477D6D25D86845009F5E40 /* Example-iOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = 44477D8225D86846009F5E40 /* Build configuration list for PBXNativeTarget "Example-iOS" */;
buildPhases = (
44477D6A25D86845009F5E40 /* Sources */,
44477D6B25D86845009F5E40 /* Frameworks */,
44477D6C25D86845009F5E40 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "Example-iOS";
packageProductDependencies = (
440B452A25D86C0100334F54 /* SnapKit */,
);
productName = "Example-iOS";
productReference = 44477D6E25D86845009F5E40 /* Example-iOS.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
44477D6625D86845009F5E40 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1250;
LastUpgradeCheck = 1250;
TargetAttributes = {
44477D6D25D86845009F5E40 = {
CreatedOnToolsVersion = 12.5;
};
};
};
buildConfigurationList = 44477D6925D86845009F5E40 /* Build configuration list for PBXProject "Example-iOS" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 44477D6525D86845009F5E40;
productRefGroup = 44477D6F25D86845009F5E40 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
44477D6D25D86845009F5E40 /* Example-iOS */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
44477D6C25D86845009F5E40 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
44477D7E25D86846009F5E40 /* LaunchScreen.storyboard in Resources */,
44477D7B25D86846009F5E40 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
44477D6A25D86845009F5E40 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
440B452225D869A700334F54 /* SimpleLayoutViewController.swift in Sources */,
440B451E25D8696C00334F54 /* ListViewController.swift in Sources */,
440B452125D869A700334F54 /* BasicUIScrollViewController.swift in Sources */,
44477D7225D86845009F5E40 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
44477D7C25D86846009F5E40 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
44477D7D25D86846009F5E40 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
44477D8025D86846009F5E40 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
44477D8125D86846009F5E40 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
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;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.5;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
44477D8325D86846009F5E40 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.Example-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
44477D8425D86846009F5E40 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.Example-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
44477D6925D86845009F5E40 /* Build configuration list for PBXProject "Example-iOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
44477D8025D86846009F5E40 /* Debug */,
44477D8125D86846009F5E40 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
44477D8225D86846009F5E40 /* Build configuration list for PBXNativeTarget "Example-iOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
44477D8325D86846009F5E40 /* Debug */,
44477D8425D86846009F5E40 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCSwiftPackageProductDependency section */
440B452A25D86C0100334F54 /* SnapKit */ = {
isa = XCSwiftPackageProductDependency;
productName = SnapKit;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 44477D6625D86845009F5E40 /* Project object */;
}

View File

@ -39,8 +39,8 @@ class ListViewController: UITableViewController {
let viewController = SimpleLayoutViewController() let viewController = SimpleLayoutViewController()
navigationController?.pushViewController(viewController, animated: true) navigationController?.pushViewController(viewController, animated: true)
} else if indexPath.row == 1 { } else if indexPath.row == 1 {
let viewController = ViewController() let viewController = BasicUIScrollViewController()
navigationController?.pushViewController(viewController, animated: true) navigationController?.pushViewController(viewController, animated: true)
} }
} }
} }

View File

@ -1,3 +1,4 @@
// swift-tools-version:5.0
// //
// SnapKit // SnapKit
// //
@ -25,5 +26,21 @@
import PackageDescription import PackageDescription
let package = Package( let package = Package(
name: "SnapKit" name: "SnapKit",
platforms: [
.iOS(.v10),
.macOS(.v10_11),
.tvOS(.v10)
],
products: [
.library(name: "SnapKit", targets: ["SnapKit"]),
.library(name: "SnapKit-Dynamic", type: .dynamic, targets: ["SnapKit"]),
],
targets: [
.target(name: "SnapKit", path: "Sources"),
.testTarget(name: "SnapKitTests", dependencies: ["SnapKit"]),
],
swiftLanguageVersions: [
.v5
]
) )

View File

@ -1,4 +1,4 @@
<img src="http://snapkit.io/images/banner.jpg" alt="" /> <img src="https://snapkit.github.io/SnapKit/images/banner.jpg" alt="" />
SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. SnapKit is a DSL to make Auto Layout easy on both iOS and OS X.
@ -7,8 +7,8 @@ SnapKit is a DSL to make Auto Layout easy on both iOS and OS X.
[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/SnapKit.svg)](https://cocoapods.org/pods/SnapKit) [![Cocoapods Compatible](https://img.shields.io/cocoapods/v/SnapKit.svg)](https://cocoapods.org/pods/SnapKit)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
#### ⚠️ **To use with Swift 3.x please ensure you are using >= 3.0.0** ⚠️ #### ⚠️ **To use with Swift 4.x please ensure you are using >= 4.0.0** ⚠️
#### ⚠️ **To use with Swift 4.x please ensure you are using >= 4.0.0** ⚠️ #### ⚠️ **To use with Swift 5.x please ensure you are using >= 5.0.0** ⚠️
## Contents ## Contents
@ -22,9 +22,13 @@ SnapKit is a DSL to make Auto Layout easy on both iOS and OS X.
## Requirements ## Requirements
- iOS 8.0+ / Mac OS X 10.11+ / tvOS 9.0+ - iOS 10.0+ / Mac OS X 10.12+ / tvOS 10.0+
- Xcode 9.0+ - Xcode 10.0+
- Swift 3.0+ - Swift 4.0+
## Migration Guides
- [SnapKit 3.0 Migration Guide](Documentation/SnapKit%203.0%20Migration%20Guide.md)
## Communication ## Communication
@ -55,7 +59,7 @@ platform :ios, '10.0'
use_frameworks! use_frameworks!
target '<Your Target Name>' do target '<Your Target Name>' do
pod 'SnapKit', '~> 4.0.0' pod 'SnapKit', '~> 5.6.0'
end end
``` ```
@ -79,11 +83,25 @@ $ brew install carthage
To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`: To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl ```ogdl
github "SnapKit/SnapKit" ~> 4.0.0 github "SnapKit/SnapKit" ~> 5.0.0
``` ```
Run `carthage update` to build the framework and drag the built `SnapKit.framework` into your Xcode project. Run `carthage update` to build the framework and drag the built `SnapKit.framework` into your Xcode project.
### Swift Package Manager
[Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. Its integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
> Xcode 11+ is required to build SnapKit using Swift Package Manager.
To integrate SnapKit into your Xcode project using Swift Package Manager, add it to the dependencies value of your `Package.swift`:
```swift
dependencies: [
.package(url: "https://github.com/SnapKit/SnapKit.git", .upToNextMajor(from: "5.0.1"))
]
```
### Manually ### Manually
If you prefer not to use either of the aforementioned dependency managers, you can integrate SnapKit into your project manually. If you prefer not to use either of the aforementioned dependency managers, you can integrate SnapKit into your project manually.
@ -105,6 +123,7 @@ class MyViewController: UIViewController {
super.viewDidLoad() super.viewDidLoad()
self.view.addSubview(box) self.view.addSubview(box)
box.backgroundColor = .green
box.snp.makeConstraints { (make) -> Void in box.snp.makeConstraints { (make) -> Void in
make.width.height.equalTo(50) make.width.height.equalTo(50)
make.center.equalTo(self.view) make.center.equalTo(self.view)
@ -114,10 +133,17 @@ class MyViewController: UIViewController {
} }
``` ```
### Playground
You can try SnapKit in Playground.
**Note:**
> To try SnapKit in playground, open `SnapKit.xcworkspace` and build SnapKit.framework for any simulator first.
### Resources ### Resources
- [Documentation](http://snapkit.io/docs/) - [Documentation](https://snapkit.github.io/SnapKit/docs/)
- [F.A.Q.](http://snapkit.io/faq/) - [F.A.Q.](https://snapkit.github.io/SnapKit/faq/)
## Credits ## Credits

View File

@ -1,18 +1,18 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'SnapKit' s.name = 'SnapKit'
s.version = '4.0.0' s.version = '5.6.0'
s.license = 'MIT' s.license = 'MIT'
s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.' s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.'
s.homepage = 'https://github.com/SnapKit/SnapKit' s.homepage = 'https://github.com/SnapKit/SnapKit'
s.authors = { 'Robert Payne' => 'robertpayne@me.com' } s.authors = { 'Robert Payne' => 'robertpayne@me.com' }
s.social_media_url = 'http://twitter.com/robertjpayne' s.social_media_url = 'http://twitter.com/robertjpayne'
s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '4.0.0' } s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '5.0.1' }
s.ios.deployment_target = '8.0' s.ios.deployment_target = '10.0'
s.osx.deployment_target = '10.11' s.osx.deployment_target = '10.11'
s.tvos.deployment_target = '9.0' s.tvos.deployment_target = '10.0'
s.source_files = 'Source/*.swift' s.source_files = 'Sources/*.swift'
s.requires_arc = true s.swift_version = '5.0'
end end

View File

@ -8,6 +8,9 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
2DBA080E1F1FAD66001CFED4 /* Typealiases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DBA080D1F1FAD66001CFED4 /* Typealiases.swift */; }; 2DBA080E1F1FAD66001CFED4 /* Typealiases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DBA080D1F1FAD66001CFED4 /* Typealiases.swift */; };
3CA7D6C224592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA7D6C124592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift */; };
7E1CB2AE227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1CB2AD227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift */; };
7E1CB2B0227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1CB2AF227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift */; };
EE235F5F1C5785BC00C08960 /* Debugging.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F5E1C5785BC00C08960 /* Debugging.swift */; }; EE235F5F1C5785BC00C08960 /* Debugging.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F5E1C5785BC00C08960 /* Debugging.swift */; };
EE235F6D1C5785C600C08960 /* Constraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F621C5785C600C08960 /* Constraint.swift */; }; EE235F6D1C5785C600C08960 /* Constraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F621C5785C600C08960 /* Constraint.swift */; };
EE235F701C5785C600C08960 /* ConstraintDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F631C5785C600C08960 /* ConstraintDescription.swift */; }; EE235F701C5785C600C08960 /* ConstraintDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F631C5785C600C08960 /* ConstraintDescription.swift */; };
@ -26,7 +29,7 @@
EE235FA31C5785CE00C08960 /* ConstraintInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */; }; EE235FA31C5785CE00C08960 /* ConstraintInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */; };
EE235FAC1C5785D400C08960 /* ConstraintMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA61C5785D400C08960 /* ConstraintMaker.swift */; }; EE235FAC1C5785D400C08960 /* ConstraintMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA61C5785D400C08960 /* ConstraintMaker.swift */; };
EE235FAF1C5785D400C08960 /* ConstraintMakerFinalizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */; }; EE235FAF1C5785D400C08960 /* ConstraintMakerFinalizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */; };
EE235FB21C5785D400C08960 /* ConstraintMakerPriortizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA81C5785D400C08960 /* ConstraintMakerPriortizable.swift */; }; EE235FB21C5785D400C08960 /* ConstraintMakerPrioritizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA81C5785D400C08960 /* ConstraintMakerPrioritizable.swift */; };
EE235FB51C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */; }; EE235FB51C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */; };
EE235FB81C5785D400C08960 /* ConstraintMakerRelatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */; }; EE235FB81C5785D400C08960 /* ConstraintMakerRelatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */; };
EE235FBB1C5785D400C08960 /* ConstraintMakerExtendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */; }; EE235FBB1C5785D400C08960 /* ConstraintMakerExtendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */; };
@ -36,7 +39,6 @@
EE4910991B19A40200A54F1F /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; EE4910991B19A40200A54F1F /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; };
EE6087751E4F133E0029CF84 /* ConstraintPriority.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE6087741E4F133E0029CF84 /* ConstraintPriority.swift */; }; EE6087751E4F133E0029CF84 /* ConstraintPriority.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE6087741E4F133E0029CF84 /* ConstraintPriority.swift */; };
EE6898CB1DA7B3A100D47F33 /* LayoutConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE6898CA1DA7B3A100D47F33 /* LayoutConstraintItem.swift */; }; EE6898CB1DA7B3A100D47F33 /* LayoutConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE6898CA1DA7B3A100D47F33 /* LayoutConstraintItem.swift */; };
EECDB3741AC0C9B6006BBC11 /* SnapKit.h in Headers */ = {isa = PBXBuildFile; fileRef = EECDB3661AC0C95C006BBC11 /* SnapKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
EECDB3931AC0CB52006BBC11 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; }; EECDB3931AC0CB52006BBC11 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; };
EEF68F9E1D78492400980C26 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */; }; EEF68F9E1D78492400980C26 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */; };
EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */; }; EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */; };
@ -48,7 +50,10 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
2DBA080D1F1FAD66001CFED4 /* Typealiases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typealiases.swift; sourceTree = "<group>"; }; 2DBA080D1F1FAD66001CFED4 /* Typealiases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typealiases.swift; sourceTree = "<group>"; };
3CA7D6C124592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConstraintMakerRelatable+Extensions.swift"; sourceTree = "<group>"; };
537DCE9A1C35CD4100B5B899 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 537DCE9A1C35CD4100B5B899 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
7E1CB2AD227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintDirectionalInsetTarget.swift; sourceTree = "<group>"; };
7E1CB2AF227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintDirectionalInsets.swift; sourceTree = "<group>"; };
EE235F5E1C5785BC00C08960 /* Debugging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Debugging.swift; sourceTree = "<group>"; }; EE235F5E1C5785BC00C08960 /* Debugging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Debugging.swift; sourceTree = "<group>"; };
EE235F621C5785C600C08960 /* Constraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constraint.swift; sourceTree = "<group>"; }; EE235F621C5785C600C08960 /* Constraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constraint.swift; sourceTree = "<group>"; };
EE235F631C5785C600C08960 /* ConstraintDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDescription.swift; sourceTree = "<group>"; }; EE235F631C5785C600C08960 /* ConstraintDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDescription.swift; sourceTree = "<group>"; };
@ -67,7 +72,7 @@
EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintInsetTarget.swift; sourceTree = "<group>"; }; EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintInsetTarget.swift; sourceTree = "<group>"; };
EE235FA61C5785D400C08960 /* ConstraintMaker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMaker.swift; sourceTree = "<group>"; }; EE235FA61C5785D400C08960 /* ConstraintMaker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMaker.swift; sourceTree = "<group>"; };
EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerFinalizable.swift; sourceTree = "<group>"; }; EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerFinalizable.swift; sourceTree = "<group>"; };
EE235FA81C5785D400C08960 /* ConstraintMakerPriortizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerPriortizable.swift; sourceTree = "<group>"; }; EE235FA81C5785D400C08960 /* ConstraintMakerPrioritizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerPrioritizable.swift; sourceTree = "<group>"; };
EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerEditable.swift; sourceTree = "<group>"; }; EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerEditable.swift; sourceTree = "<group>"; };
EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerRelatable.swift; sourceTree = "<group>"; }; EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerRelatable.swift; sourceTree = "<group>"; };
EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerExtendable.swift; sourceTree = "<group>"; }; EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerExtendable.swift; sourceTree = "<group>"; };
@ -76,14 +81,13 @@
EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintView+Extensions.swift"; sourceTree = "<group>"; }; EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintView+Extensions.swift"; sourceTree = "<group>"; };
EE6087741E4F133E0029CF84 /* ConstraintPriority.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintPriority.swift; sourceTree = "<group>"; }; EE6087741E4F133E0029CF84 /* ConstraintPriority.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintPriority.swift; sourceTree = "<group>"; };
EE6898CA1DA7B3A100D47F33 /* LayoutConstraintItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutConstraintItem.swift; sourceTree = "<group>"; }; EE6898CA1DA7B3A100D47F33 /* LayoutConstraintItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutConstraintItem.swift; sourceTree = "<group>"; };
EE6DB559251D9A6B00E0C374 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; }; EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; };
EEBCC9D819CC627D0083B827 /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EEBCC9D819CC627D0083B827 /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EEBCC9E219CC627E0083B827 /* SnapKit Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SnapKit Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; EEBCC9E219CC627E0083B827 /* SnapKit Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SnapKit Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
EECDB3641AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; EECDB3691AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = SnapKitTests/Info.plist; sourceTree = "<group>"; };
EECDB3661AC0C95C006BBC11 /* SnapKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SnapKit.h; sourceTree = "<group>"; }; EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Tests.swift; path = SnapKitTests/Tests.swift; sourceTree = "<group>"; };
EECDB3691AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuideDSL.swift; sourceTree = "<group>"; }; EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuideDSL.swift; sourceTree = "<group>"; };
EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDSL.swift; sourceTree = "<group>"; }; EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDSL.swift; sourceTree = "<group>"; };
EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintLayoutGuide+Extensions.swift"; sourceTree = "<group>"; }; EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintLayoutGuide+Extensions.swift"; sourceTree = "<group>"; };
@ -114,7 +118,8 @@
DDC9FD8C1981B4DD009612C7 = { DDC9FD8C1981B4DD009612C7 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
EECDB35D1AC0C95C006BBC11 /* Source */, EE6DB557251D9A6B00E0C374 /* Supporting Files */,
EECDB35D1AC0C95C006BBC11 /* Sources */,
EE94F60C1AC0F113008767FF /* Frameworks */, EE94F60C1AC0F113008767FF /* Frameworks */,
DDC9FD961981B4DD009612C7 /* Products */, DDC9FD961981B4DD009612C7 /* Products */,
); );
@ -135,6 +140,7 @@
EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */, EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */,
EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */, EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */,
EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */, EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */,
3CA7D6C124592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift */,
); );
name = Extensions; name = Extensions;
sourceTree = "<group>"; sourceTree = "<group>";
@ -155,7 +161,7 @@
children = ( children = (
EE235FA61C5785D400C08960 /* ConstraintMaker.swift */, EE235FA61C5785D400C08960 /* ConstraintMaker.swift */,
EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */, EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */,
EE235FA81C5785D400C08960 /* ConstraintMakerPriortizable.swift */, EE235FA81C5785D400C08960 /* ConstraintMakerPrioritizable.swift */,
EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */, EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */,
EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */, EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */,
EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */, EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */,
@ -172,6 +178,7 @@
EE235F911C5785CE00C08960 /* ConstraintMultiplierTarget.swift */, EE235F911C5785CE00C08960 /* ConstraintMultiplierTarget.swift */,
EE235F921C5785CE00C08960 /* ConstraintOffsetTarget.swift */, EE235F921C5785CE00C08960 /* ConstraintOffsetTarget.swift */,
EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */, EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */,
7E1CB2AD227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift */,
); );
name = Targets; name = Targets;
sourceTree = "<group>"; sourceTree = "<group>";
@ -183,6 +190,7 @@
EE235F621C5785C600C08960 /* Constraint.swift */, EE235F621C5785C600C08960 /* Constraint.swift */,
EE235F631C5785C600C08960 /* ConstraintDescription.swift */, EE235F631C5785C600C08960 /* ConstraintDescription.swift */,
EE235F641C5785C600C08960 /* ConstraintInsets.swift */, EE235F641C5785C600C08960 /* ConstraintInsets.swift */,
7E1CB2AF227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift */,
EE235F651C5785C600C08960 /* ConstraintConfig.swift */, EE235F651C5785C600C08960 /* ConstraintConfig.swift */,
EE235F661C5785C600C08960 /* ConstraintView.swift */, EE235F661C5785C600C08960 /* ConstraintView.swift */,
EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */, EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */,
@ -205,6 +213,14 @@
name = Debugging; name = Debugging;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
EE6DB557251D9A6B00E0C374 /* Supporting Files */ = {
isa = PBXGroup;
children = (
EE6DB559251D9A6B00E0C374 /* Info.plist */,
);
path = "Supporting Files";
sourceTree = "<group>";
};
EE94F60C1AC0F113008767FF /* Frameworks */ = { EE94F60C1AC0F113008767FF /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -215,20 +231,18 @@
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
EECDB35D1AC0C95C006BBC11 /* Source */ = { EECDB35D1AC0C95C006BBC11 /* Sources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
EECDB3661AC0C95C006BBC11 /* SnapKit.h */,
EE235F581C57858700C08960 /* Extensions */, EE235F581C57858700C08960 /* Extensions */,
EE235F591C57859200C08960 /* DSLs */, EE235F591C57859200C08960 /* DSLs */,
EE235F5A1C57859900C08960 /* Maker */, EE235F5A1C57859900C08960 /* Maker */,
EE235F5B1C57859E00C08960 /* Targets */, EE235F5B1C57859E00C08960 /* Targets */,
EE235F5C1C5785A400C08960 /* Models */, EE235F5C1C5785A400C08960 /* Models */,
EE235F5D1C5785AC00C08960 /* Debugging */, EE235F5D1C5785AC00C08960 /* Debugging */,
EECDB36B1AC0C967006BBC11 /* Supporting Files */,
EECDB3681AC0C95C006BBC11 /* Tests */, EECDB3681AC0C95C006BBC11 /* Tests */,
); );
path = Source; path = Sources;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
EECDB3681AC0C95C006BBC11 /* Tests */ = { EECDB3681AC0C95C006BBC11 /* Tests */ = {
@ -241,14 +255,6 @@
path = ../Tests; path = ../Tests;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
EECDB36B1AC0C967006BBC11 /* Supporting Files */ = {
isa = PBXGroup;
children = (
EECDB3641AC0C95C006BBC11 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */ /* Begin PBXHeadersBuildPhase section */
@ -256,7 +262,6 @@
isa = PBXHeadersBuildPhase; isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
EECDB3741AC0C9B6006BBC11 /* SnapKit.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -305,23 +310,23 @@
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastSwiftUpdateCheck = 0720; LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0900; LastUpgradeCheck = 1230;
ORGANIZATIONNAME = "SnapKit Team"; ORGANIZATIONNAME = "SnapKit Team";
TargetAttributes = { TargetAttributes = {
EEBCC9D719CC627D0083B827 = { EEBCC9D719CC627D0083B827 = {
CreatedOnToolsVersion = 6.0; CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0900; LastSwiftMigration = 1020;
}; };
EEBCC9E119CC627D0083B827 = { EEBCC9E119CC627D0083B827 = {
CreatedOnToolsVersion = 6.0; CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0900; LastSwiftMigration = 1020;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
}; };
}; };
buildConfigurationList = DDC9FD901981B4DD009612C7 /* Build configuration list for PBXProject "SnapKit" */; buildConfigurationList = DDC9FD901981B4DD009612C7 /* Build configuration list for PBXProject "SnapKit" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English; developmentRegion = en;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
knownRegions = ( knownRegions = (
en, en,
@ -371,6 +376,7 @@
EE235FB51C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */, EE235FB51C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */,
EEF68FBC1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */, EEF68FBC1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */,
EE235FAC1C5785D400C08960 /* ConstraintMaker.swift in Sources */, EE235FAC1C5785D400C08960 /* ConstraintMaker.swift in Sources */,
7E1CB2AE227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift in Sources */,
EE6087751E4F133E0029CF84 /* ConstraintPriority.swift in Sources */, EE6087751E4F133E0029CF84 /* ConstraintPriority.swift in Sources */,
EE235F941C5785CE00C08960 /* ConstraintRelatableTarget.swift in Sources */, EE235F941C5785CE00C08960 /* ConstraintRelatableTarget.swift in Sources */,
EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */, EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */,
@ -384,13 +390,15 @@
EE235F6D1C5785C600C08960 /* Constraint.swift in Sources */, EE235F6D1C5785C600C08960 /* Constraint.swift in Sources */,
EE235F791C5785C600C08960 /* ConstraintView.swift in Sources */, EE235F791C5785C600C08960 /* ConstraintView.swift in Sources */,
EE6898CB1DA7B3A100D47F33 /* LayoutConstraintItem.swift in Sources */, EE6898CB1DA7B3A100D47F33 /* LayoutConstraintItem.swift in Sources */,
EE235FB21C5785D400C08960 /* ConstraintMakerPriortizable.swift in Sources */, EE235FB21C5785D400C08960 /* ConstraintMakerPrioritizable.swift in Sources */,
EE235F8B1C5785C600C08960 /* LayoutConstraint.swift in Sources */, EE235F8B1C5785C600C08960 /* LayoutConstraint.swift in Sources */,
7E1CB2B0227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift in Sources */,
EE235FA31C5785CE00C08960 /* ConstraintInsetTarget.swift in Sources */, EE235FA31C5785CE00C08960 /* ConstraintInsetTarget.swift in Sources */,
EE235F9D1C5785CE00C08960 /* ConstraintMultiplierTarget.swift in Sources */, EE235F9D1C5785CE00C08960 /* ConstraintMultiplierTarget.swift in Sources */,
EE235FC01C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */, EE235FC01C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */,
EE235F5F1C5785BC00C08960 /* Debugging.swift in Sources */, EE235F5F1C5785BC00C08960 /* Debugging.swift in Sources */,
EE235FC31C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */, EE235FC31C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */,
3CA7D6C224592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift in Sources */,
EE235F7F1C5785C600C08960 /* ConstraintRelation.swift in Sources */, EE235F7F1C5785C600C08960 /* ConstraintRelation.swift in Sources */,
EEF68FB41D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */, EEF68FB41D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */,
EE235F701C5785C600C08960 /* ConstraintDescription.swift in Sources */, EE235F701C5785C600C08960 /* ConstraintDescription.swift in Sources */,
@ -412,6 +420,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
@ -420,14 +429,17 @@
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES; CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
@ -469,6 +481,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
@ -477,14 +490,17 @@
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES; CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
@ -523,15 +539,17 @@
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK; PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
PRODUCT_NAME = SnapKit; PRODUCT_NAME = SnapKit;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
name = Debug; name = Debug;
@ -546,14 +564,16 @@
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK; PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
PRODUCT_NAME = SnapKit; PRODUCT_NAME = SnapKit;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
name = Release; name = Release;
@ -563,11 +583,13 @@
buildSettings = { buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/Tests/SnapKitTests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
}; };
name = Debug; name = Debug;
}; };
@ -576,12 +598,14 @@
buildSettings = { buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/Tests/SnapKitTests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
}; };
name = Release; name = Release;
}; };

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0900" LastUpgradeVersion = "1230"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EEBCC9D719CC627D0083B827"
BuildableName = "SnapKit.framework"
BlueprintName = "SnapKit"
ReferencedContainer = "container:SnapKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">
@ -39,17 +48,6 @@
</BuildableReference> </BuildableReference>
</TestableReference> </TestableReference>
</Testables> </Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EEBCC9D719CC627D0083B827"
BuildableName = "SnapKit.framework"
BlueprintName = "SnapKit"
ReferencedContainer = "container:SnapKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
@ -70,8 +68,6 @@
ReferencedContainer = "container:SnapKit.xcodeproj"> ReferencedContainer = "container:SnapKit.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Workspace <Workspace
version = "1.0"> version = "1.0">
<FileRef
location = "group:SnapKitPlayground.playground">
</FileRef>
<FileRef <FileRef
location = "container:SnapKit.xcodeproj"> location = "container:SnapKit.xcodeproj">
</FileRef> </FileRef>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,29 @@
//: A UIKit based Playground for presenting user interface
// To use this playground, build SnapKit.framework for any simulator first.
import SnapKit
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white
let label = UILabel()
label.text = "Hello World!"
label.textColor = .black
view.addSubview(label)
label.snp.makeConstraints { (make) in
make.left.equalToSuperview().offset(150)
make.top.equalToSuperview().offset(200)
make.size.equalTo(CGSize(width: 200, height: 20))
}
self.view = view
}
}
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = MyViewController()

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' executeOnSourceChanges='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
</Workspace>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
</TimelineItems>
</Timeline>

View File

@ -1,152 +0,0 @@
//
// SnapKit
//
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS) || os(tvOS)
import UIKit
#else
import AppKit
#endif
public extension ConstraintView {
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_left: ConstraintItem { return self.snp.left }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_top: ConstraintItem { return self.snp.top }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_right: ConstraintItem { return self.snp.right }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_bottom: ConstraintItem { return self.snp.bottom }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_leading: ConstraintItem { return self.snp.leading }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_trailing: ConstraintItem { return self.snp.trailing }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_width: ConstraintItem { return self.snp.width }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_height: ConstraintItem { return self.snp.height }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_centerX: ConstraintItem { return self.snp.centerX }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_centerY: ConstraintItem { return self.snp.centerY }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_baseline: ConstraintItem { return self.snp.baseline }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, OSX 10.11, *)
public var snp_lastBaseline: ConstraintItem { return self.snp.lastBaseline }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, OSX 10.11, *)
public var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_leftMargin: ConstraintItem { return self.snp.leftMargin }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_topMargin: ConstraintItem { return self.snp.topMargin }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_rightMargin: ConstraintItem { return self.snp.rightMargin }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_edges: ConstraintItem { return self.snp.edges }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_size: ConstraintItem { return self.snp.size }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public var snp_center: ConstraintItem { return self.snp.center }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_margins: ConstraintItem { return self.snp.margins }
@available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.")
@available(iOS 8.0, *)
public var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] {
return self.snp.prepareConstraints(closure)
}
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.makeConstraints(closure)
}
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.remakeConstraints(closure)
}
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.updateConstraints(closure)
}
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.")
public func snp_removeConstraints() {
self.snp.removeConstraints()
}
public var snp: ConstraintViewDSL {
return ConstraintViewDSL(view: self)
}
}

View File

@ -49,12 +49,23 @@ public final class Constraint {
public var layoutConstraints: [LayoutConstraint] public var layoutConstraints: [LayoutConstraint]
public var isActive: Bool { public var isActive: Bool {
for layoutConstraint in self.layoutConstraints { set {
if layoutConstraint.isActive { if newValue {
return true activate()
}
else {
deactivate()
} }
} }
return false
get {
for layoutConstraint in self.layoutConstraints {
if layoutConstraint.isActive {
return true
}
}
return false
}
} }
// MARK: Initialization // MARK: Initialization
@ -118,6 +129,32 @@ public final class Constraint {
default: default:
fatalError() fatalError()
} }
} else if self.from.attributes == .directionalEdges && self.to.attributes == .directionalMargins {
switch layoutFromAttribute {
case .leading:
layoutToAttribute = .leadingMargin
case .trailing:
layoutToAttribute = .trailingMargin
case .top:
layoutToAttribute = .topMargin
case .bottom:
layoutToAttribute = .bottomMargin
default:
fatalError()
}
} else if self.from.attributes == .directionalMargins && self.to.attributes == .directionalEdges {
switch layoutFromAttribute {
case .leadingMargin:
layoutToAttribute = .leading
case .trailingMargin:
layoutToAttribute = .trailing
case .topMargin:
layoutToAttribute = .top
case .bottomMargin:
layoutToAttribute = .bottom
default:
fatalError()
}
} else if self.from.attributes == self.to.attributes { } else if self.from.attributes == self.to.attributes {
layoutToAttribute = layoutFromAttribute layoutToAttribute = layoutFromAttribute
} else { } else {
@ -178,12 +215,12 @@ public final class Constraint {
// MARK: Public // MARK: Public
@available(*, deprecated:3.0, message:"Use activate().") @available(*, deprecated, renamed:"activate()")
public func install() { public func install() {
self.activate() self.activate()
} }
@available(*, deprecated:3.0, message:"Use deactivate().") @available(*, deprecated, renamed:"deactivate()")
public func uninstall() { public func uninstall() {
self.deactivate() self.deactivate()
} }
@ -208,31 +245,46 @@ public final class Constraint {
return self return self
} }
#if os(iOS) || os(tvOS)
@discardableResult
@available(iOS 11.0, tvOS 11.0, *)
public func update(inset: ConstraintDirectionalInsetTarget) -> Constraint {
self.constant = inset.constraintDirectionalInsetTargetValue
return self
}
#endif
@discardableResult @discardableResult
public func update(priority: ConstraintPriorityTarget) -> Constraint { public func update(priority: ConstraintPriorityTarget) -> Constraint {
self.priority = priority.constraintPriorityTargetValue self.priority = priority.constraintPriorityTargetValue
return self return self
} }
@available(*, deprecated:3.0, message:"Use update(offset: ConstraintOffsetTarget) instead.") @discardableResult
public func update(priority: ConstraintPriority) -> Constraint {
self.priority = priority.value
return self
}
@available(*, deprecated, renamed:"update(offset:)")
public func updateOffset(amount: ConstraintOffsetTarget) -> Void { self.update(offset: amount) } public func updateOffset(amount: ConstraintOffsetTarget) -> Void { self.update(offset: amount) }
@available(*, deprecated:3.0, message:"Use update(inset: ConstraintInsetTarget) instead.") @available(*, deprecated, renamed:"update(inset:)")
public func updateInsets(amount: ConstraintInsetTarget) -> Void { self.update(inset: amount) } public func updateInsets(amount: ConstraintInsetTarget) -> Void { self.update(inset: amount) }
@available(*, deprecated:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") @available(*, deprecated, renamed:"update(priority:)")
public func updatePriority(amount: ConstraintPriorityTarget) -> Void { self.update(priority: amount) } public func updatePriority(amount: ConstraintPriorityTarget) -> Void { self.update(priority: amount) }
@available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.")
public func updatePriorityRequired() -> Void {} public func updatePriorityRequired() -> Void {}
@available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.")
public func updatePriorityHigh() -> Void { fatalError("Must be implemented by Concrete subclass.") } public func updatePriorityHigh() -> Void { fatalError("Must be implemented by Concrete subclass.") }
@available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.")
public func updatePriorityMedium() -> Void { fatalError("Must be implemented by Concrete subclass.") } public func updatePriorityMedium() -> Void { fatalError("Must be implemented by Concrete subclass.") }
@available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.")
public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") } public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") }
// MARK: Internal // MARK: Internal

View File

@ -28,7 +28,9 @@
#endif #endif
internal struct ConstraintAttributes : OptionSet { internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral {
typealias IntegerLiteralType = UInt
internal init(rawValue: UInt) { internal init(rawValue: UInt) {
self.rawValue = rawValue self.rawValue = rawValue
@ -39,10 +41,13 @@ internal struct ConstraintAttributes : OptionSet {
internal init(nilLiteral: ()) { internal init(nilLiteral: ()) {
self.rawValue = 0 self.rawValue = 0
} }
internal init(integerLiteral rawValue: IntegerLiteralType) {
self.init(rawValue: rawValue)
}
internal private(set) var rawValue: UInt internal private(set) var rawValue: UInt
internal static var allZeros: ConstraintAttributes { return self.init(0) } internal static var allZeros: ConstraintAttributes { return 0 }
internal static func convertFromNilLiteral() -> ConstraintAttributes { return self.init(0) } internal static func convertFromNilLiteral() -> ConstraintAttributes { return 0 }
internal var boolValue: Bool { return self.rawValue != 0 } internal var boolValue: Bool { return self.rawValue != 0 }
internal func toRaw() -> UInt { return self.rawValue } internal func toRaw() -> UInt { return self.rawValue }
@ -51,57 +56,65 @@ internal struct ConstraintAttributes : OptionSet {
// normal // normal
internal static var none: ConstraintAttributes { return self.init(0) } internal static let none: ConstraintAttributes = 0
internal static var left: ConstraintAttributes { return self.init(1) } internal static let left: ConstraintAttributes = ConstraintAttributes(UInt(1) << 0)
internal static var top: ConstraintAttributes { return self.init(2) } internal static let top: ConstraintAttributes = ConstraintAttributes(UInt(1) << 1)
internal static var right: ConstraintAttributes { return self.init(4) } internal static let right: ConstraintAttributes = ConstraintAttributes(UInt(1) << 2)
internal static var bottom: ConstraintAttributes { return self.init(8) } internal static let bottom: ConstraintAttributes = ConstraintAttributes(UInt(1) << 3)
internal static var leading: ConstraintAttributes { return self.init(16) } internal static let leading: ConstraintAttributes = ConstraintAttributes(UInt(1) << 4)
internal static var trailing: ConstraintAttributes { return self.init(32) } internal static let trailing: ConstraintAttributes = ConstraintAttributes(UInt(1) << 5)
internal static var width: ConstraintAttributes { return self.init(64) } internal static let width: ConstraintAttributes = ConstraintAttributes(UInt(1) << 6)
internal static var height: ConstraintAttributes { return self.init(128) } internal static let height: ConstraintAttributes = ConstraintAttributes(UInt(1) << 7)
internal static var centerX: ConstraintAttributes { return self.init(256) } internal static let centerX: ConstraintAttributes = ConstraintAttributes(UInt(1) << 8)
internal static var centerY: ConstraintAttributes { return self.init(512) } internal static let centerY: ConstraintAttributes = ConstraintAttributes(UInt(1) << 9)
internal static var lastBaseline: ConstraintAttributes { return self.init(1024) } internal static let lastBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 10)
@available(iOS 8.0, OSX 10.11, *) @available(iOS 8.0, OSX 10.11, *)
internal static var firstBaseline: ConstraintAttributes { return self.init(2048) } internal static let firstBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 11)
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var leftMargin: ConstraintAttributes { return self.init(4096) } internal static let leftMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 12)
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var rightMargin: ConstraintAttributes { return self.init(8192) } internal static let rightMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 13)
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var topMargin: ConstraintAttributes { return self.init(16384) } internal static let topMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 14)
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var bottomMargin: ConstraintAttributes { return self.init(32768) } internal static let bottomMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 15)
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var leadingMargin: ConstraintAttributes { return self.init(65536) } internal static let leadingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 16)
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var trailingMargin: ConstraintAttributes { return self.init(131072) } internal static let trailingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 17)
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var centerXWithinMargins: ConstraintAttributes { return self.init(262144) } internal static let centerXWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 18)
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var centerYWithinMargins: ConstraintAttributes { return self.init(524288) } internal static let centerYWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 19)
// aggregates // aggregates
internal static var edges: ConstraintAttributes { return self.init(15) } internal static let edges: ConstraintAttributes = [.horizontalEdges, .verticalEdges]
internal static var size: ConstraintAttributes { return self.init(192) } internal static let horizontalEdges: ConstraintAttributes = [.left, .right]
internal static var center: ConstraintAttributes { return self.init(768) } internal static let verticalEdges: ConstraintAttributes = [.top, .bottom]
internal static let directionalEdges: ConstraintAttributes = [.directionalHorizontalEdges, .directionalVerticalEdges]
internal static let directionalHorizontalEdges: ConstraintAttributes = [.leading, .trailing]
internal static let directionalVerticalEdges: ConstraintAttributes = [.top, .bottom]
internal static let size: ConstraintAttributes = [.width, .height]
internal static let center: ConstraintAttributes = [.centerX, .centerY]
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var margins: ConstraintAttributes { return self.init(61440) } internal static let margins: ConstraintAttributes = [.leftMargin, .topMargin, .rightMargin, .bottomMargin]
@available(iOS 8.0, *) @available(iOS 8.0, *)
internal static var centerWithinMargins: ConstraintAttributes { return self.init(786432) } internal static let directionalMargins: ConstraintAttributes = [.leadingMargin, .topMargin, .trailingMargin, .bottomMargin]
@available(iOS 8.0, *)
internal static let centerWithinMargins: ConstraintAttributes = [.centerXWithinMargins, .centerYWithinMargins]
internal var layoutAttributes:[LayoutAttribute] { internal var layoutAttributes:[LayoutAttribute] {
var attrs = [LayoutAttribute]() var attrs = [LayoutAttribute]()

View File

@ -40,6 +40,12 @@ extension CGSize: ConstraintConstantTarget {
extension ConstraintInsets: ConstraintConstantTarget { extension ConstraintInsets: ConstraintConstantTarget {
} }
#if os(iOS) || os(tvOS)
@available(iOS 11.0, tvOS 11.0, *)
extension ConstraintDirectionalInsets: ConstraintConstantTarget {
}
#endif
extension ConstraintConstantTarget { extension ConstraintConstantTarget {
internal func constraintConstantTargetValueFor(layoutAttribute: LayoutAttribute) -> CGFloat { internal func constraintConstantTargetValueFor(layoutAttribute: LayoutAttribute) -> CGFloat {
@ -82,7 +88,11 @@ extension ConstraintConstantTarget {
return value.y return value.y
case .width, .height, .notAnAttribute: case .width, .height, .notAnAttribute:
return 0.0 return 0.0
} #if swift(>=5.0)
@unknown default:
return 0.0
#endif
}
#else #else
switch layoutAttribute { switch layoutAttribute {
case .left, .right, .leading, .trailing, .centerX: case .left, .right, .leading, .trailing, .centerX:
@ -91,56 +101,112 @@ extension ConstraintConstantTarget {
return value.y return value.y
case .width, .height, .notAnAttribute: case .width, .height, .notAnAttribute:
return 0.0 return 0.0
} #if swift(>=5.0)
@unknown default:
return 0.0
#endif
}
#endif #endif
} }
if let value = self as? ConstraintInsets { if let value = self as? ConstraintInsets {
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
switch layoutAttribute { switch layoutAttribute {
case .left, .leftMargin, .centerX, .centerXWithinMargins: case .left, .leftMargin:
return value.left return value.left
case .top, .topMargin, .centerY, .centerYWithinMargins, .lastBaseline, .firstBaseline: case .top, .topMargin, .firstBaseline:
return value.top return value.top
case .right, .rightMargin: case .right, .rightMargin:
return -value.right return -value.right
case .bottom, .bottomMargin: case .bottom, .bottomMargin, .lastBaseline:
return -value.bottom return -value.bottom
case .leading, .leadingMargin: case .leading, .leadingMargin:
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right
case .trailing, .trailingMargin: case .trailing, .trailingMargin:
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left
case .centerX, .centerXWithinMargins:
return (value.left - value.right) / 2
case .centerY, .centerYWithinMargins:
return (value.top - value.bottom) / 2
case .width: case .width:
return -(value.left + value.right) return -(value.left + value.right)
case .height: case .height:
return -(value.top + value.bottom) return -(value.top + value.bottom)
case .notAnAttribute: case .notAnAttribute:
return 0.0 return 0.0
} #if swift(>=5.0)
@unknown default:
return 0.0
#endif
}
#else #else
switch layoutAttribute { switch layoutAttribute {
case .left, .centerX: case .left:
return value.left return value.left
case .top, .centerY, .lastBaseline, .firstBaseline: case .top, .firstBaseline:
return value.top return value.top
case .right: case .right:
return -value.right return -value.right
case .bottom: case .bottom, .lastBaseline:
return -value.bottom return -value.bottom
case .leading: case .leading:
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right
case .trailing: case .trailing:
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left
case .centerX:
return (value.left - value.right) / 2
case .centerY:
return (value.top - value.bottom) / 2
case .width: case .width:
return -(value.left + value.right) return -(value.left + value.right)
case .height: case .height:
return -(value.top + value.bottom) return -(value.top + value.bottom)
case .notAnAttribute: case .notAnAttribute:
return 0.0 return 0.0
} #if swift(>=5.0)
@unknown default:
return 0.0
#endif
}
#endif #endif
} }
#if os(iOS) || os(tvOS)
if #available(iOS 11.0, tvOS 11.0, *), let value = self as? ConstraintDirectionalInsets {
switch layoutAttribute {
case .left, .leftMargin:
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.leading : value.trailing
case .top, .topMargin, .firstBaseline:
return value.top
case .right, .rightMargin:
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.trailing : -value.leading
case .bottom, .bottomMargin, .lastBaseline:
return -value.bottom
case .leading, .leadingMargin:
return value.leading
case .trailing, .trailingMargin:
return -value.trailing
case .centerX, .centerXWithinMargins:
return (value.leading - value.trailing) / 2
case .centerY, .centerYWithinMargins:
return (value.top - value.bottom) / 2
case .width:
return -(value.leading + value.trailing)
case .height:
return -(value.top + value.bottom)
case .notAnAttribute:
return 0.0
#if swift(>=5.0)
@unknown default:
return 0.0
#else
default:
return 0.0
#endif
}
}
#endif
return 0.0 return 0.0
} }

View File

@ -99,6 +99,26 @@ extension ConstraintBasicAttributesDSL {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.edges) return ConstraintItem(target: self.target, attributes: ConstraintAttributes.edges)
} }
public var directionalEdges: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalEdges)
}
public var horizontalEdges: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.horizontalEdges)
}
public var verticalEdges: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.verticalEdges)
}
public var directionalHorizontalEdges: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalHorizontalEdges)
}
public var directionalVerticalEdges: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalVerticalEdges)
}
public var size: ConstraintItem { public var size: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.size) return ConstraintItem(target: self.target, attributes: ConstraintAttributes.size)
} }
@ -114,8 +134,7 @@ public protocol ConstraintAttributesDSL : ConstraintBasicAttributesDSL {
extension ConstraintAttributesDSL { extension ConstraintAttributesDSL {
// MARK: Baselines // MARK: Baselines
@available(*, deprecated, renamed:"lastBaseline")
@available(*, deprecated:3.0, message:"Use .lastBaseline instead")
public var baseline: ConstraintItem { public var baseline: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline) return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline)
} }
@ -177,6 +196,11 @@ extension ConstraintAttributesDSL {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.margins) return ConstraintItem(target: self.target, attributes: ConstraintAttributes.margins)
} }
@available(iOS 8.0, *)
public var directionalMargins: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalMargins)
}
@available(iOS 8.0, *) @available(iOS 8.0, *)
public var centerWithinMargins: ConstraintItem { public var centerWithinMargins: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerWithinMargins) return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerWithinMargins)

View File

@ -0,0 +1,49 @@
//
// SnapKit
//
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS) || os(tvOS)
import UIKit
#else
import AppKit
#endif
#if os(iOS) || os(tvOS)
public protocol ConstraintDirectionalInsetTarget: ConstraintConstantTarget {
}
@available(iOS 11.0, tvOS 11.0, *)
extension ConstraintDirectionalInsets: ConstraintDirectionalInsetTarget {
}
extension ConstraintDirectionalInsetTarget {
@available(iOS 11.0, tvOS 11.0, *)
internal var constraintDirectionalInsetTargetValue: ConstraintDirectionalInsets {
if let amount = self as? ConstraintDirectionalInsets {
return amount
} else {
return ConstraintDirectionalInsets(top: 0, leading: 0, bottom: 0, trailing: 0)
}
}
}
#endif

View File

@ -21,7 +21,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
#import <Foundation/Foundation.h> #if os(iOS) || os(tvOS)
import UIKit
#else
import AppKit
#endif
FOUNDATION_EXPORT double SnapKitVersionNumber;
FOUNDATION_EXPORT const unsigned char SnapKitVersionString[]; #if os(iOS) || os(tvOS)
@available(iOS 11.0, tvOS 11.0, *)
public typealias ConstraintDirectionalInsets = NSDirectionalEdgeInsets
#endif

View File

@ -29,7 +29,7 @@
@available(iOS 9.0, OSX 10.11, *) @available(iOS 9.0, OSX 10.11, *)
public extension ConstraintLayoutGuide { public extension ConstraintLayoutGuide {
public var snp: ConstraintLayoutGuideDSL { var snp: ConstraintLayoutGuideDSL {
return ConstraintLayoutGuideDSL(guide: self) return ConstraintLayoutGuideDSL(guide: self)
} }

View File

@ -69,7 +69,7 @@ public class ConstraintMaker {
return self.makeExtendableWithAttributes(.centerY) return self.makeExtendableWithAttributes(.centerY)
} }
@available(*, deprecated:3.0, message:"Use lastBaseline instead") @available(*, deprecated, renamed:"lastBaseline")
public var baseline: ConstraintMakerExtendable { public var baseline: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.lastBaseline) return self.makeExtendableWithAttributes(.lastBaseline)
} }
@ -126,6 +126,21 @@ public class ConstraintMaker {
public var edges: ConstraintMakerExtendable { public var edges: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.edges) return self.makeExtendableWithAttributes(.edges)
} }
public var horizontalEdges: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.horizontalEdges)
}
public var verticalEdges: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.verticalEdges)
}
public var directionalEdges: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.directionalEdges)
}
public var directionalHorizontalEdges: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.directionalHorizontalEdges)
}
public var directionalVerticalEdges: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.directionalVerticalEdges)
}
public var size: ConstraintMakerExtendable { public var size: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.size) return self.makeExtendableWithAttributes(.size)
} }
@ -138,12 +153,17 @@ public class ConstraintMaker {
return self.makeExtendableWithAttributes(.margins) return self.makeExtendableWithAttributes(.margins)
} }
@available(iOS 8.0, *)
public var directionalMargins: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.directionalMargins)
}
@available(iOS 8.0, *) @available(iOS 8.0, *)
public var centerWithinMargins: ConstraintMakerExtendable { public var centerWithinMargins: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.centerWithinMargins) return self.makeExtendableWithAttributes(.centerWithinMargins)
} }
private let item: LayoutConstraintItem public let item: LayoutConstraintItem
private var descriptions = [ConstraintDescription]() private var descriptions = [ConstraintDescription]()
internal init(item: LayoutConstraintItem) { internal init(item: LayoutConstraintItem) {
@ -171,15 +191,7 @@ public class ConstraintMaker {
} }
internal static func makeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) { internal static func makeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) {
let maker = ConstraintMaker(item: item) let constraints = prepareConstraints(item: item, closure: closure)
closure(maker)
var constraints: [Constraint] = []
for description in maker.descriptions {
guard let constraint = description.constraint else {
continue
}
constraints.append(constraint)
}
for constraint in constraints { for constraint in constraints {
constraint.activateIfNeeded(updatingExisting: false) constraint.activateIfNeeded(updatingExisting: false)
} }
@ -196,15 +208,7 @@ public class ConstraintMaker {
return return
} }
let maker = ConstraintMaker(item: item) let constraints = prepareConstraints(item: item, closure: closure)
closure(maker)
var constraints: [Constraint] = []
for description in maker.descriptions {
guard let constraint = description.constraint else {
continue
}
constraints.append(constraint)
}
for constraint in constraints { for constraint in constraints {
constraint.activateIfNeeded(updatingExisting: true) constraint.activateIfNeeded(updatingExisting: true)
} }

View File

@ -28,7 +28,7 @@
#endif #endif
public class ConstraintMakerEditable: ConstraintMakerPriortizable { public class ConstraintMakerEditable: ConstraintMakerPrioritizable {
@discardableResult @discardableResult
public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
@ -53,4 +53,12 @@ public class ConstraintMakerEditable: ConstraintMakerPriortizable {
return self return self
} }
#if os(iOS) || os(tvOS)
@discardableResult
@available(iOS 11.0, tvOS 11.0, *)
public func inset(_ amount: ConstraintDirectionalInsetTarget) -> ConstraintMakerEditable {
self.description.constant = amount.constraintDirectionalInsetTargetValue
return self
}
#endif
} }

View File

@ -80,7 +80,7 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable {
return self return self
} }
@available(*, deprecated:3.0, message:"Use lastBaseline instead") @available(*, deprecated, renamed:"lastBaseline")
public var baseline: ConstraintMakerExtendable { public var baseline: ConstraintMakerExtendable {
self.description.attributes += .lastBaseline self.description.attributes += .lastBaseline
return self return self
@ -149,6 +149,26 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable {
self.description.attributes += .edges self.description.attributes += .edges
return self return self
} }
public var horizontalEdges: ConstraintMakerExtendable {
self.description.attributes += .horizontalEdges
return self
}
public var verticalEdges: ConstraintMakerExtendable {
self.description.attributes += .verticalEdges
return self
}
public var directionalEdges: ConstraintMakerExtendable {
self.description.attributes += .directionalEdges
return self
}
public var directionalHorizontalEdges: ConstraintMakerExtendable {
self.description.attributes += .directionalHorizontalEdges
return self
}
public var directionalVerticalEdges: ConstraintMakerExtendable {
self.description.attributes += .directionalVerticalEdges
return self
}
public var size: ConstraintMakerExtendable { public var size: ConstraintMakerExtendable {
self.description.attributes += .size self.description.attributes += .size
return self return self
@ -160,6 +180,12 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable {
return self return self
} }
@available(iOS 8.0, *)
public var directionalMargins: ConstraintMakerExtendable {
self.description.attributes += .directionalMargins
return self
}
@available(iOS 8.0, *) @available(iOS 8.0, *)
public var centerWithinMargins: ConstraintMakerExtendable { public var centerWithinMargins: ConstraintMakerExtendable {
self.description.attributes += .centerWithinMargins self.description.attributes += .centerWithinMargins

View File

@ -27,8 +27,10 @@
import AppKit import AppKit
#endif #endif
@available(*, deprecated, message:"Use ConstraintMakerPrioritizable instead.")
public typealias ConstraintMakerPriortizable = ConstraintMakerPrioritizable
public class ConstraintMakerPriortizable: ConstraintMakerFinalizable { public class ConstraintMakerPrioritizable: ConstraintMakerFinalizable {
@discardableResult @discardableResult
public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable { public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable {
@ -42,25 +44,25 @@ public class ConstraintMakerPriortizable: ConstraintMakerFinalizable {
return self return self
} }
@available(*, deprecated:3.0, message:"Use priority(.required) instead.") @available(*, deprecated, message:"Use priority(.required) instead.")
@discardableResult @discardableResult
public func priorityRequired() -> ConstraintMakerFinalizable { public func priorityRequired() -> ConstraintMakerFinalizable {
return self.priority(.required) return self.priority(.required)
} }
@available(*, deprecated:3.0, message:"Use priority(.high) instead.") @available(*, deprecated, message:"Use priority(.high) instead.")
@discardableResult @discardableResult
public func priorityHigh() -> ConstraintMakerFinalizable { public func priorityHigh() -> ConstraintMakerFinalizable {
return self.priority(.high) return self.priority(.high)
} }
@available(*, deprecated:3.0, message:"Use priority(.medium) instead.") @available(*, deprecated, message:"Use priority(.medium) instead.")
@discardableResult @discardableResult
public func priorityMedium() -> ConstraintMakerFinalizable { public func priorityMedium() -> ConstraintMakerFinalizable {
return self.priority(.medium) return self.priority(.medium)
} }
@available(*, deprecated:3.0, message:"Use priority(.low) instead.") @available(*, deprecated, message:"Use priority(.low) instead.")
@discardableResult @discardableResult
public func priorityLow() -> ConstraintMakerFinalizable { public func priorityLow() -> ConstraintMakerFinalizable {
return self.priority(.low) return self.priority(.low)

View File

@ -0,0 +1,57 @@
//
// SnapKit
//
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS) || os(tvOS)
import UIKit
#else
import AppKit
#endif
extension ConstraintMakerRelatable {
@discardableResult
public func equalToSuperview<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
guard let other = self.description.item.superview else {
fatalError("Expected superview but found nil when attempting make constraint `equalToSuperview`.")
}
return self.relatedTo(closure(other), relation: .equal, file: file, line: line)
}
@discardableResult
public func lessThanOrEqualToSuperview<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
guard let other = self.description.item.superview else {
fatalError("Expected superview but found nil when attempting make constraint `lessThanOrEqualToSuperview`.")
}
return self.relatedTo(closure(other), relation: .lessThanOrEqual, file: file, line: line)
}
@discardableResult
public func greaterThanOrEqualTo<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
guard let other = self.description.item.superview else {
fatalError("Expected superview but found nil when attempting make constraint `greaterThanOrEqualToSuperview`.")
}
return self.relatedTo(closure(other), relation: .greaterThanOrEqual, file: file, line: line)
}
}

View File

@ -45,7 +45,9 @@ public class ConstraintMakerRelatable {
other.attributes.layoutAttributes.count <= 1 || other.attributes.layoutAttributes.count <= 1 ||
other.attributes.layoutAttributes == self.description.attributes.layoutAttributes || other.attributes.layoutAttributes == self.description.attributes.layoutAttributes ||
other.attributes == .edges && self.description.attributes == .margins || other.attributes == .edges && self.description.attributes == .margins ||
other.attributes == .margins && self.description.attributes == .edges else { other.attributes == .margins && self.description.attributes == .edges ||
other.attributes == .directionalEdges && self.description.attributes == .directionalMargins ||
other.attributes == .directionalMargins && self.description.attributes == .directionalEdges else {
fatalError("Cannot constraint to multiple non identical attributes. (\(file), \(line))"); fatalError("Cannot constraint to multiple non identical attributes. (\(file), \(line))");
} }

View File

@ -73,3 +73,13 @@ extension CGFloat: ConstraintPriorityTarget {
} }
} }
#if os(iOS) || os(tvOS)
extension UILayoutPriority: ConstraintPriorityTarget {
public var constraintPriorityTargetValue: Float {
return self.rawValue
}
}
#endif

View File

@ -55,6 +55,12 @@ extension CGPoint: ConstraintRelatableTarget {
extension ConstraintInsets: ConstraintRelatableTarget { extension ConstraintInsets: ConstraintRelatableTarget {
} }
#if os(iOS) || os(tvOS)
@available(iOS 11.0, tvOS 11.0, *)
extension ConstraintDirectionalInsets: ConstraintRelatableTarget {
}
#endif
extension ConstraintItem: ConstraintRelatableTarget { extension ConstraintItem: ConstraintRelatableTarget {
} }

View File

@ -0,0 +1,152 @@
//
// SnapKit
//
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS) || os(tvOS)
import UIKit
#else
import AppKit
#endif
public extension ConstraintView {
@available(*, deprecated, renamed:"snp.left")
var snp_left: ConstraintItem { return self.snp.left }
@available(*, deprecated, renamed:"snp.top")
var snp_top: ConstraintItem { return self.snp.top }
@available(*, deprecated, renamed:"snp.right")
var snp_right: ConstraintItem { return self.snp.right }
@available(*, deprecated, renamed:"snp.bottom")
var snp_bottom: ConstraintItem { return self.snp.bottom }
@available(*, deprecated, renamed:"snp.leading")
var snp_leading: ConstraintItem { return self.snp.leading }
@available(*, deprecated, renamed:"snp.trailing")
var snp_trailing: ConstraintItem { return self.snp.trailing }
@available(*, deprecated, renamed:"snp.width")
var snp_width: ConstraintItem { return self.snp.width }
@available(*, deprecated, renamed:"snp.height")
var snp_height: ConstraintItem { return self.snp.height }
@available(*, deprecated, renamed:"snp.centerX")
var snp_centerX: ConstraintItem { return self.snp.centerX }
@available(*, deprecated, renamed:"snp.centerY")
var snp_centerY: ConstraintItem { return self.snp.centerY }
@available(*, deprecated, renamed:"snp.baseline")
var snp_baseline: ConstraintItem { return self.snp.baseline }
@available(*, deprecated, renamed:"snp.lastBaseline")
@available(iOS 8.0, OSX 10.11, *)
var snp_lastBaseline: ConstraintItem { return self.snp.lastBaseline }
@available(iOS, deprecated, renamed:"snp.firstBaseline")
@available(iOS 8.0, OSX 10.11, *)
var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline }
@available(iOS, deprecated, renamed:"snp.leftMargin")
@available(iOS 8.0, *)
var snp_leftMargin: ConstraintItem { return self.snp.leftMargin }
@available(iOS, deprecated, renamed:"snp.topMargin")
@available(iOS 8.0, *)
var snp_topMargin: ConstraintItem { return self.snp.topMargin }
@available(iOS, deprecated, renamed:"snp.rightMargin")
@available(iOS 8.0, *)
var snp_rightMargin: ConstraintItem { return self.snp.rightMargin }
@available(iOS, deprecated, renamed:"snp.bottomMargin")
@available(iOS 8.0, *)
var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin }
@available(iOS, deprecated, renamed:"snp.leadingMargin")
@available(iOS 8.0, *)
var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin }
@available(iOS, deprecated, renamed:"snp.trailingMargin")
@available(iOS 8.0, *)
var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin }
@available(iOS, deprecated, renamed:"snp.centerXWithinMargins")
@available(iOS 8.0, *)
var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins }
@available(iOS, deprecated, renamed:"snp.centerYWithinMargins")
@available(iOS 8.0, *)
var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins }
@available(*, deprecated, renamed:"snp.edges")
var snp_edges: ConstraintItem { return self.snp.edges }
@available(*, deprecated, renamed:"snp.size")
var snp_size: ConstraintItem { return self.snp.size }
@available(*, deprecated, renamed:"snp.center")
var snp_center: ConstraintItem { return self.snp.center }
@available(iOS, deprecated, renamed:"snp.margins")
@available(iOS 8.0, *)
var snp_margins: ConstraintItem { return self.snp.margins }
@available(iOS, deprecated, renamed:"snp.centerWithinMargins")
@available(iOS 8.0, *)
var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins }
@available(*, deprecated, renamed:"snp.prepareConstraints(_:)")
func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] {
return self.snp.prepareConstraints(closure)
}
@available(*, deprecated, renamed:"snp.makeConstraints(_:)")
func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.makeConstraints(closure)
}
@available(*, deprecated, renamed:"snp.remakeConstraints(_:)")
func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.remakeConstraints(closure)
}
@available(*, deprecated, renamed:"snp.updateConstraints(_:)")
func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.updateConstraints(closure)
}
@available(*, deprecated, renamed:"snp.removeConstraints()")
func snp_removeConstraints() {
self.snp.removeConstraints()
}
var snp: ConstraintViewDSL {
return ConstraintViewDSL(view: self)
}
}

View File

@ -55,7 +55,7 @@ public struct ConstraintViewDSL: ConstraintAttributesDSL {
get { get {
return self.view.contentHuggingPriority(for: .horizontal).rawValue return self.view.contentHuggingPriority(for: .horizontal).rawValue
} }
set { nonmutating set {
self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .horizontal) self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .horizontal)
} }
} }
@ -64,7 +64,7 @@ public struct ConstraintViewDSL: ConstraintAttributesDSL {
get { get {
return self.view.contentHuggingPriority(for: .vertical).rawValue return self.view.contentHuggingPriority(for: .vertical).rawValue
} }
set { nonmutating set {
self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .vertical) self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .vertical)
} }
} }
@ -73,7 +73,7 @@ public struct ConstraintViewDSL: ConstraintAttributesDSL {
get { get {
return self.view.contentCompressionResistancePriority(for: .horizontal).rawValue return self.view.contentCompressionResistancePriority(for: .horizontal).rawValue
} }
set { nonmutating set {
self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .horizontal) self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .horizontal)
} }
} }
@ -82,7 +82,7 @@ public struct ConstraintViewDSL: ConstraintAttributesDSL {
get { get {
return self.view.contentCompressionResistancePriority(for: .vertical).rawValue return self.view.contentCompressionResistancePriority(for: .vertical).rawValue
} }
set { nonmutating set {
self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .vertical) self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .vertical)
} }
} }

View File

@ -29,7 +29,7 @@
public extension LayoutConstraint { public extension LayoutConstraint {
override public var description: String { override var description: String {
var description = "<" var description = "<"
description += descriptionForObject(self) description += descriptionForObject(self)
@ -82,6 +82,9 @@ private func descriptionForRelation(_ relation: LayoutRelation) -> String {
case .equal: return "==" case .equal: return "=="
case .greaterThanOrEqual: return ">=" case .greaterThanOrEqual: return ">="
case .lessThanOrEqual: return "<=" case .lessThanOrEqual: return "<="
#if swift(>=5.0)
@unknown default: return "unknown"
#endif
} }
} }
@ -109,7 +112,10 @@ private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String {
case .trailingMargin: return "trailingMargin" case .trailingMargin: return "trailingMargin"
case .centerXWithinMargins: return "centerXWithinMargins" case .centerXWithinMargins: return "centerXWithinMargins"
case .centerYWithinMargins: return "centerYWithinMargins" case .centerYWithinMargins: return "centerYWithinMargins"
} #if swift(>=5.0)
@unknown default: return "unknown"
#endif
}
#else #else
switch attribute { switch attribute {
case .notAnAttribute: return "notAnAttribute" case .notAnAttribute: return "notAnAttribute"
@ -125,7 +131,10 @@ private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String {
case .centerY: return "centerY" case .centerY: return "centerY"
case .lastBaseline: return "lastBaseline" case .lastBaseline: return "lastBaseline"
case .firstBaseline: return "firstBaseline" case .firstBaseline: return "firstBaseline"
} #if swift(>=5.0)
@unknown default: return "unknown"
#endif
}
#endif #endif
} }

View File

@ -44,13 +44,17 @@ public class LayoutConstraint : NSLayoutConstraint {
} }
internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool {
guard lhs.firstItem === rhs.firstItem && // If firstItem or secondItem on either constraint has a dangling pointer
lhs.secondItem === rhs.secondItem && // this comparison can cause a crash. The solution for this is to ensure
lhs.firstAttribute == rhs.firstAttribute && // your layout code hold strong references to things like Views, LayoutGuides
// and LayoutAnchors as SnapKit will not keep strong references to any of these.
guard lhs.firstAttribute == rhs.firstAttribute &&
lhs.secondAttribute == rhs.secondAttribute && lhs.secondAttribute == rhs.secondAttribute &&
lhs.relation == rhs.relation && lhs.relation == rhs.relation &&
lhs.priority == rhs.priority && lhs.priority == rhs.priority &&
lhs.multiplier == rhs.multiplier else { lhs.multiplier == rhs.multiplier &&
lhs.secondItem === rhs.secondItem &&
lhs.firstItem === rhs.firstItem else {
return false return false
} }
return true return true

View File

@ -28,7 +28,7 @@
#endif #endif
public protocol LayoutConstraintItem: class { public protocol LayoutConstraintItem: AnyObject {
} }
@available(iOS 9.0, OSX 10.11, *) @available(iOS 9.0, OSX 10.11, *)

View File

@ -25,8 +25,13 @@ import Foundation
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
import UIKit import UIKit
#if swift(>=4.2)
typealias LayoutRelation = NSLayoutConstraint.Relation
typealias LayoutAttribute = NSLayoutConstraint.Attribute
#else
typealias LayoutRelation = NSLayoutRelation typealias LayoutRelation = NSLayoutRelation
typealias LayoutAttribute = NSLayoutAttribute typealias LayoutAttribute = NSLayoutAttribute
#endif
typealias LayoutPriority = UILayoutPriority typealias LayoutPriority = UILayoutPriority
#else #else
import AppKit import AppKit

View File

@ -29,7 +29,7 @@
@available(iOS 8.0, *) @available(iOS 8.0, *)
public extension ConstraintLayoutSupport { public extension ConstraintLayoutSupport {
public var snp: ConstraintLayoutSupportDSL { var snp: ConstraintLayoutSupportDSL {
return ConstraintLayoutSupportDSL(support: self) return ConstraintLayoutSupportDSL(support: self)
} }

View File

@ -59,6 +59,46 @@ class SnapKitTests: XCTestCase {
XCTAssertEqual(self.container.snp_constraints.count, 6, "Should have 6 constraints installed") XCTAssertEqual(self.container.snp_constraints.count, 6, "Should have 6 constraints installed")
} }
func testHorizontalVerticalEdges() {
let v1 = View()
self.container.addSubview(v1)
v1.snp.makeConstraints { (make) -> Void in
make.verticalEdges.equalToSuperview()
make.horizontalEdges.equalToSuperview()
return
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints installed")
XCTAssertTrue(container.constraints.count == 4)
XCTAssertTrue(container.constraints.allSatisfy { $0.firstItem === v1 && $0.secondItem === v1.superview })
XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .left && $0.secondAttribute == .left })
XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .right && $0.secondAttribute == .right })
XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .top && $0.secondAttribute == .top })
XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .bottom && $0.secondAttribute == .bottom })
}
func testHorizontalVerticalDirectionalEdges() {
let v1 = View()
self.container.addSubview(v1)
v1.snp.makeConstraints { (make) -> Void in
make.directionalVerticalEdges.equalToSuperview()
make.directionalHorizontalEdges.equalToSuperview()
return
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints installed")
XCTAssertTrue(container.constraints.count == 4)
XCTAssertTrue(container.constraints.allSatisfy { $0.firstItem === v1 && $0.secondItem === v1.superview })
XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .leading && $0.secondAttribute == .leading })
XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .trailing && $0.secondAttribute == .trailing })
XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .top && $0.secondAttribute == .top })
XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .bottom && $0.secondAttribute == .bottom })
}
func testGuideMakeConstraints() { func testGuideMakeConstraints() {
guard #available(iOS 9.0, OSX 10.11, *) else { return } guard #available(iOS 9.0, OSX 10.11, *) else { return }
@ -264,6 +304,40 @@ class SnapKitTests: XCTestCase {
} }
func testSetIsActivatedConstraints() {
let v1 = View()
let v2 = View()
self.container.addSubview(v1)
self.container.addSubview(v2)
var c1: Constraint? = nil
var c2: Constraint? = nil
v1.snp.prepareConstraints { (make) -> Void in
c1 = make.top.equalTo(v2.snp.top).offset(50).constraint
c2 = make.left.equalTo(v2.snp.top).offset(50).constraint
return
}
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints")
c1?.isActive = true
c2?.isActive = false
XCTAssertEqual(self.container.snp_constraints.count, 1, "Should have 1 constraint")
c1?.isActive = true
c2?.isActive = true
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints")
c1?.isActive = false
c2?.isActive = false
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints")
}
func testEdgeConstraints() { func testEdgeConstraints() {
let view = View() let view = View()
self.container.addSubview(view) self.container.addSubview(view)
@ -379,6 +453,90 @@ class SnapKitTests: XCTestCase {
XCTAssertEqual(constraints[3].constant, -25, "Should be -25") XCTAssertEqual(constraints[3].constant, -25, "Should be -25")
} }
#if os(iOS) || os(tvOS)
@available(iOS 11.0, tvOS 11.0, *)
func testConstraintDirectionalInsetsAsImpliedEqualToConstraints() {
let view = View()
self.container.addSubview(view)
view.snp.makeConstraints { (make) -> Void in
make.top.leading.bottom.trailing.equalTo(self.container).inset(ConstraintDirectionalInsets(top: 25, leading: 25, bottom: 25, trailing: 25))
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints")
let constraints = (self.container.snp_constraints as! [NSLayoutConstraint]).sorted { $0.firstAttribute.rawValue < $1.firstAttribute.rawValue }
let verify: (NSLayoutConstraint, NSLayoutConstraint.Attribute, CGFloat) -> Void = { constraint, attribute, constant in
XCTAssertEqual(constraint.firstAttribute, attribute, "First attribute \(constraint.firstAttribute.rawValue) is not \(attribute.rawValue)")
XCTAssertEqual(constraint.secondAttribute, attribute, "Second attribute \(constraint.secondAttribute.rawValue) is not \(attribute.rawValue)")
XCTAssertEqual(constraint.constant, constant, "Attribute \(attribute.rawValue) should have constant \(constant)")
}
verify(constraints[0], .top, 25)
verify(constraints[1], .bottom, -25)
verify(constraints[2], .leading, 25)
verify(constraints[3], .trailing, -25)
}
#endif
#if os(iOS) || os(tvOS)
@available(iOS 11.0, tvOS 11.0, *)
func testConstraintDirectionalInsetsAsConstraintsConstant() {
let view = View()
self.container.addSubview(view)
view.snp.makeConstraints { (make) -> Void in
make.top.leading.bottom.trailing.equalTo(self.container).inset(ConstraintDirectionalInsets(top: 25, leading: 25, bottom: 25, trailing: 25))
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints")
let constraints = (self.container.snp_constraints as! [NSLayoutConstraint]).sorted { $0.firstAttribute.rawValue < $1.firstAttribute.rawValue }
let verify: (NSLayoutConstraint, NSLayoutConstraint.Attribute, CGFloat) -> Void = { constraint, attribute, constant in
XCTAssertEqual(constraint.firstAttribute, attribute, "First attribute \(constraint.firstAttribute.rawValue) is not \(attribute.rawValue)")
XCTAssertEqual(constraint.secondAttribute, attribute, "Second attribute \(constraint.secondAttribute.rawValue) is not \(attribute.rawValue)")
XCTAssertEqual(constraint.constant, constant, "Attribute \(attribute.rawValue) should have constant \(constant)")
}
verify(constraints[0], .top, 25)
verify(constraints[1], .bottom, -25)
verify(constraints[2], .leading, 25)
verify(constraints[3], .trailing, -25)
}
#endif
#if os(iOS) || os(tvOS)
@available(iOS 11.0, tvOS 11.0, *)
func testConstraintDirectionalInsetsFallBackForNonDirectionalConstraints() {
let view = View()
self.container.addSubview(view)
view.snp.makeConstraints { (make) -> Void in
make.edges.equalTo(self.container).inset(ConstraintDirectionalInsets(top: 25, leading: 25, bottom: 25, trailing: 25))
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints")
let constraints = (self.container.snp_constraints as! [NSLayoutConstraint]).sorted { $0.firstAttribute.rawValue < $1.firstAttribute.rawValue }
let verify: (NSLayoutConstraint, NSLayoutConstraint.Attribute, CGFloat) -> Void = { constraint, attribute, constant in
XCTAssertEqual(constraint.firstAttribute, attribute, "First attribute \(constraint.firstAttribute.rawValue) is not \(attribute.rawValue)")
XCTAssertEqual(constraint.secondAttribute, attribute, "Second attribute \(constraint.secondAttribute.rawValue) is not \(attribute.rawValue)")
XCTAssertEqual(constraint.constant, constant, "Attribute \(attribute.rawValue) should have constant \(constant)")
}
verify(constraints[0], .left, 25)
verify(constraints[1], .right, -25)
verify(constraints[2], .top, 25)
verify(constraints[3], .bottom, -25)
}
#endif
func testSizeConstraints() { func testSizeConstraints() {
let view = View() let view = View()
self.container.addSubview(view) self.container.addSubview(view)
@ -457,11 +615,33 @@ class SnapKitTests: XCTestCase {
XCTAssert(fromAttributes == [.top, .left, .bottom, .right]) XCTAssert(fromAttributes == [.top, .left, .bottom, .right])
XCTAssert(toAttributes == [.top, .left, .bottom, .right]) XCTAssert(toAttributes == [.top, .left, .bottom, .right])
} }
func testDirectionalEdgesToDirectionalEdges() {
var fromAttributes = Set<LayoutAttribute>()
var toAttributes = Set<LayoutAttribute>()
let view = View()
self.container.addSubview(view)
view.snp.remakeConstraints { (make) -> Void in
make.directionalEdges.equalTo(self.container.snp.directionalEdges)
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints")
for constraint in (container.snp_constraints as! [NSLayoutConstraint]) {
fromAttributes.insert(constraint.firstAttribute)
toAttributes.insert(constraint.secondAttribute)
}
XCTAssert(fromAttributes == [.top, .leading, .bottom, .trailing])
XCTAssert(toAttributes == [.top, .leading, .bottom, .trailing])
}
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
func testEdgesToMargins() { func testEdgesToMargins() {
var fromAttributes = Set<NSLayoutAttribute>() var fromAttributes = Set<LayoutAttribute>()
var toAttributes = Set<NSLayoutAttribute>() var toAttributes = Set<LayoutAttribute>()
let view = View() let view = View()
self.container.addSubview(view) self.container.addSubview(view)
@ -498,6 +678,46 @@ class SnapKitTests: XCTestCase {
XCTAssert(fromAttributes == [.topMargin, .leftMargin, .bottomMargin, .rightMargin]) XCTAssert(fromAttributes == [.topMargin, .leftMargin, .bottomMargin, .rightMargin])
} }
func testDirectionalEdgesToDirectionalMargins() {
var fromAttributes = Set<LayoutAttribute>()
var toAttributes = Set<LayoutAttribute>()
let view = View()
self.container.addSubview(view)
view.snp.remakeConstraints { (make) -> Void in
make.directionalEdges.equalTo(self.container.snp.directionalMargins)
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints")
for constraint in (container.snp_constraints as! [NSLayoutConstraint]) {
fromAttributes.insert(constraint.firstAttribute)
toAttributes.insert(constraint.secondAttribute)
}
XCTAssert(fromAttributes == [.top, .leading, .bottom, .trailing])
XCTAssert(toAttributes == [.topMargin, .leadingMargin, .bottomMargin, .trailingMargin])
fromAttributes.removeAll()
toAttributes.removeAll()
view.snp.remakeConstraints { (make) -> Void in
make.directionalMargins.equalTo(self.container.snp.directionalEdges)
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints")
for constraint in (container.snp_constraints as! [NSLayoutConstraint]) {
fromAttributes.insert(constraint.firstAttribute)
toAttributes.insert(constraint.secondAttribute)
}
XCTAssert(toAttributes == [.top, .leading, .bottom, .trailing])
XCTAssert(fromAttributes == [.topMargin, .leadingMargin, .bottomMargin, .trailingMargin])
}
func testLayoutGuideConstraints() { func testLayoutGuideConstraints() {
let vc = UIViewController() let vc = UIViewController()
@ -516,6 +736,8 @@ class SnapKitTests: XCTestCase {
func testCanSetLabel() { func testCanSetLabel() {
self.container.snp.setLabel("Hello World") self.container.snp.setLabel("Hello World")
XCTAssertEqual(self.container.snp.label(), "Hello World")
} }
func testPriorityShortcuts() { func testPriorityShortcuts() {