diff --git a/.gitignore b/.gitignore index c32722f..5f8d191 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ DerivedData *.ipa *.xcuserstate -Carthage/ +Pods/ +.DS_Store \ No newline at end of file diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..9f55b2c --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 diff --git a/.travis.yml b/.travis.yml index f442e6a..5f05510 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,13 @@ language: objective-c -osx_image: xcode7.3 -before_install: -- brew update -- brew install carthage || brew outdated carthage || brew upgrade carthage +osx_image: xcode8 install: - gem install xcpretty -- carthage bootstrap --platform "ios osx" +- gem install cocoapods --pre script: -- set -o pipefail && xcodebuild -scheme 'Cartography-Mac' test | xcpretty -c -- set -o pipefail && xcodebuild -scheme 'Cartography-iOS' -sdk iphonesimulator test | xcpretty -c +- pod update +- set -o pipefail && xcodebuild -workspace Cartography.xcworkspace -scheme 'Cartography-Mac' test | xcpretty -c +- set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace ./Cartography.xcworkspace -scheme Cartography-iOS -destination 'platform=iOS Simulator,name=iPhone 6s Plus' build test | xcpretty + env: global: secure: odPR+Uvp5Enxc8qlFxuUo+aYVf1zS9xF7t2at4IXAJtP0wegwmG8dYOZ5IiMZP/gbBtAWWYc2en4NVnqS9K9wPFIrKdShMwBGnRcsYPj3b6kH/vQM/OLwzYFit2oSqhR3n4RP5UM+lc4jJnfqrK7StMY6ZxCkvLdZkMbFGqVJ20= diff --git a/Cartfile.private b/Cartfile.private deleted file mode 100644 index 72a43a5..0000000 --- a/Cartfile.private +++ /dev/null @@ -1,2 +0,0 @@ -github "Quick/Nimble" ~> 4.0 -github "Quick/Quick" ~> 0.9 diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index 35cc93d..0000000 --- a/Cartfile.resolved +++ /dev/null @@ -1,2 +0,0 @@ -github "Quick/Nimble" "v4.0.0" -github "Quick/Quick" "v0.9.2" diff --git a/Cartography.xcodeproj/project.pbxproj b/Cartography.xcodeproj/project.pbxproj index a7fcc48..d53270b 100644 --- a/Cartography.xcodeproj/project.pbxproj +++ b/Cartography.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 09F7751A581957EA262BC6A4 /* Pods_TestPods_Cartography_Mac_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 825625A8CCFA9B2B102BDDDB /* Pods_TestPods_Cartography_Mac_Tests.framework */; }; + 40F7238205F9E56862357198 /* Pods_TestPods_Cartography_iOS_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C63D81EB2304A489BE29E6A /* Pods_TestPods_Cartography_iOS_Tests.framework */; }; 4A3756C91D67445F0036190E /* LayoutSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66AF7EED1CABEABC00249E27 /* LayoutSupport.swift */; }; 4A3756CB1D6749190036190E /* LayoutSupportSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A3756CA1D6749180036190E /* LayoutSupportSpec.swift */; }; 4A3756CC1D6749190036190E /* LayoutSupportSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A3756CA1D6749180036190E /* LayoutSupportSpec.swift */; }; @@ -19,10 +21,6 @@ 5435B8C01AD8612C00B805F1 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5435B8B51AD8610300B805F1 /* Quick.framework */; }; 5435B8C11AD8613500B805F1 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5435B8B81AD8610300B805F1 /* Nimble.framework */; }; 5435B8C21AD8613500B805F1 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5435B8B91AD8610300B805F1 /* Quick.framework */; }; - 5435B8C51AD8615600B805F1 /* Nimble.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 5435B8B81AD8610300B805F1 /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 5435B8C61AD8615600B805F1 /* Quick.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 5435B8B91AD8610300B805F1 /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 5435B8C81AD8616900B805F1 /* Nimble.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 5435B8B41AD8610300B805F1 /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 5435B8C91AD8616900B805F1 /* Quick.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 5435B8B51AD8610300B805F1 /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 543B37FA1AC82FBF00367D8B /* Edge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 546E9E901950A76C00B16707 /* Edge.swift */; }; 545F35841ACDFF6C00B57E98 /* MemoryLeakSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 545F35831ACDFF6C00B57E98 /* MemoryLeakSpec.swift */; }; 545F35851ACDFFAF00B57E98 /* MemoryLeakSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 545F35831ACDFF6C00B57E98 /* MemoryLeakSpec.swift */; }; @@ -119,6 +117,7 @@ 632F09541BF1F15C002431A3 /* Matchers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 541305B71B495986003F1935 /* Matchers.swift */; }; 632F09551BF1F15C002431A3 /* TestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54DE2B9E1ABE2BC5004D62D8 /* TestView.swift */; }; 66AF7EEE1CABEABC00249E27 /* LayoutSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66AF7EED1CABEABC00249E27 /* LayoutSupport.swift */; }; + A75B6143FF12C54FF3223B47 /* Pods_TestPods_Cartography_tvOS_tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0827A83361EACF1E6062607E /* Pods_TestPods_Cartography_tvOS_tests.framework */; }; BBAC6D131A22A27900E8A3E2 /* ViewUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAC6D121A22A27900E8A3E2 /* ViewUtils.swift */; }; BBAC6D141A22A3AC00E8A3E2 /* ViewUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBAC6D121A22A27900E8A3E2 /* ViewUtils.swift */; }; BBAC6D1B1A22A8F300E8A3E2 /* ViewHierarchySpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB41A06E1A229BF7007142FE /* ViewHierarchySpec.swift */; }; @@ -163,8 +162,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 5435B8C51AD8615600B805F1 /* Nimble.framework in Copy Frameworks */, - 5435B8C61AD8615600B805F1 /* Quick.framework in Copy Frameworks */, ); name = "Copy Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -175,8 +172,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 5435B8C81AD8616900B805F1 /* Nimble.framework in Copy Frameworks */, - 5435B8C91AD8616900B805F1 /* Quick.framework in Copy Frameworks */, ); name = "Copy Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -184,6 +179,12 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 007A7C5A4CF651CD9D550547 /* Pods-TestPods-Cartography-iOS-Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestPods-Cartography-iOS-Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TestPods-Cartography-iOS-Tests/Pods-TestPods-Cartography-iOS-Tests.debug.xcconfig"; sourceTree = ""; }; + 0827A83361EACF1E6062607E /* Pods_TestPods_Cartography_tvOS_tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TestPods_Cartography_tvOS_tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 0C63D81EB2304A489BE29E6A /* Pods_TestPods_Cartography_iOS_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TestPods_Cartography_iOS_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 125531F897589C40A2E6968E /* Pods-TestPods-Cartography-iOS-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestPods-Cartography-iOS-Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TestPods-Cartography-iOS-Tests/Pods-TestPods-Cartography-iOS-Tests.release.xcconfig"; sourceTree = ""; }; + 3C61A3F684FD20F5E1B1F8D1 /* Pods-TestPods-Cartography-Mac-Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestPods-Cartography-Mac-Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TestPods-Cartography-Mac-Tests/Pods-TestPods-Cartography-Mac-Tests.debug.xcconfig"; sourceTree = ""; }; + 45CEEFB5D80398843533851A /* Pods-TestPods-Cartography-tvOS-tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestPods-Cartography-tvOS-tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TestPods-Cartography-tvOS-tests/Pods-TestPods-Cartography-tvOS-tests.debug.xcconfig"; sourceTree = ""; }; 4A3756CA1D6749180036190E /* LayoutSupportSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutSupportSpec.swift; sourceTree = ""; }; 541305B71B495986003F1935 /* Matchers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Matchers.swift; sourceTree = ""; }; 54143E4F1A939D6000208182 /* DistributeSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = DistributeSpec.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; @@ -229,9 +230,15 @@ 54FA3A431951A9730094B82A /* SizeSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SizeSpec.swift; sourceTree = ""; }; 632F090A1BF1E7AA002431A3 /* Cartography.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cartography.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 632F09221BF1E7FC002431A3 /* Cartography-tvOS-tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Cartography-tvOS-tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 646D273E5E982865688DF028 /* Pods_Cartography_tvOS_tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Cartography_tvOS_tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 66AF7EED1CABEABC00249E27 /* LayoutSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutSupport.swift; sourceTree = ""; }; + 690415756227F5789FBF9D77 /* Pods-TestPods-Cartography-Mac-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestPods-Cartography-Mac-Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TestPods-Cartography-Mac-Tests/Pods-TestPods-Cartography-Mac-Tests.release.xcconfig"; sourceTree = ""; }; + 7BBFE24E2FED786C571966AE /* Pods_Cartography_Mac_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Cartography_Mac_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 7D3596ED3F137EB677E57692 /* Pods-TestPods-Cartography-tvOS-tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestPods-Cartography-tvOS-tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TestPods-Cartography-tvOS-tests/Pods-TestPods-Cartography-tvOS-tests.release.xcconfig"; sourceTree = ""; }; + 825625A8CCFA9B2B102BDDDB /* Pods_TestPods_Cartography_Mac_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TestPods_Cartography_Mac_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BB41A06E1A229BF7007142FE /* ViewHierarchySpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewHierarchySpec.swift; sourceTree = ""; }; BBAC6D121A22A27900E8A3E2 /* ViewUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewUtils.swift; sourceTree = ""; }; + EEDD4098FF7503B1F9188F10 /* Pods_Cartography_iOS_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Cartography_iOS_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -249,6 +256,7 @@ 54C96A1D195063CD000CDD27 /* Cartography.framework in Frameworks */, 5435B8BF1AD8612C00B805F1 /* Nimble.framework in Frameworks */, 5435B8C01AD8612C00B805F1 /* Quick.framework in Frameworks */, + 40F7238205F9E56862357198 /* Pods_TestPods_Cartography_iOS_Tests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -266,6 +274,7 @@ 54F6A843195C20C200313D24 /* Cartography.framework in Frameworks */, 5435B8C11AD8613500B805F1 /* Nimble.framework in Frameworks */, 5435B8C21AD8613500B805F1 /* Quick.framework in Frameworks */, + 09F7751A581957EA262BC6A4 /* Pods_TestPods_Cartography_Mac_Tests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -281,12 +290,26 @@ buildActionMask = 2147483647; files = ( 632F09271BF1E7FC002431A3 /* Cartography.framework in Frameworks */, + A75B6143FF12C54FF3223B47 /* Pods_TestPods_Cartography_tvOS_tests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2F12B8E5120CB9E4A9CE0B7F /* Pods */ = { + isa = PBXGroup; + children = ( + 690415756227F5789FBF9D77 /* Pods-TestPods-Cartography-Mac-Tests.release.xcconfig */, + 007A7C5A4CF651CD9D550547 /* Pods-TestPods-Cartography-iOS-Tests.debug.xcconfig */, + 125531F897589C40A2E6968E /* Pods-TestPods-Cartography-iOS-Tests.release.xcconfig */, + 45CEEFB5D80398843533851A /* Pods-TestPods-Cartography-tvOS-tests.debug.xcconfig */, + 7D3596ED3F137EB677E57692 /* Pods-TestPods-Cartography-tvOS-tests.release.xcconfig */, + 3C61A3F684FD20F5E1B1F8D1 /* Pods-TestPods-Cartography-Mac-Tests.debug.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 5435B8B21AD8610300B805F1 /* iOS */ = { isa = PBXGroup; children = ( @@ -313,6 +336,12 @@ 632F09041BF1E771002431A3 /* tvOS */, 5435B8B21AD8610300B805F1 /* iOS */, 5435B8B61AD8610300B805F1 /* Mac */, + 7BBFE24E2FED786C571966AE /* Pods_Cartography_Mac_Tests.framework */, + EEDD4098FF7503B1F9188F10 /* Pods_Cartography_iOS_Tests.framework */, + 646D273E5E982865688DF028 /* Pods_Cartography_tvOS_tests.framework */, + 825625A8CCFA9B2B102BDDDB /* Pods_TestPods_Cartography_Mac_Tests.framework */, + 0C63D81EB2304A489BE29E6A /* Pods_TestPods_Cartography_iOS_Tests.framework */, + 0827A83361EACF1E6062607E /* Pods_TestPods_Cartography_tvOS_tests.framework */, ); name = Frameworks; sourceTree = ""; @@ -324,6 +353,7 @@ 54C96A20195063CD000CDD27 /* CartographyTests */, 5435B8BA1AD8610700B805F1 /* Frameworks */, 54C96A12195063CD000CDD27 /* Products */, + 2F12B8E5120CB9E4A9CE0B7F /* Pods */, ); sourceTree = ""; }; @@ -467,10 +497,13 @@ isa = PBXNativeTarget; buildConfigurationList = 54C96A2A195063CD000CDD27 /* Build configuration list for PBXNativeTarget "Cartography-iOS-Tests" */; buildPhases = ( + 24028C048E277759E25AE786 /* [CP] Check Pods Manifest.lock */, 54C96A18195063CD000CDD27 /* Sources */, 54C96A19195063CD000CDD27 /* Frameworks */, 54C96A1A195063CD000CDD27 /* Resources */, 5435B8C71AD8616000B805F1 /* Copy Frameworks */, + B6F7D337FFD9973F4083FCD3 /* [CP] Embed Pods Frameworks */, + 8EB90FDED8EA58C4CCBBC95A /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -505,10 +538,13 @@ isa = PBXNativeTarget; buildConfigurationList = 54F6A84E195C20C200313D24 /* Build configuration list for PBXNativeTarget "Cartography-Mac-Tests" */; buildPhases = ( + DA4D07B720B9F2E815A2DE6C /* [CP] Check Pods Manifest.lock */, 54F6A83E195C20C200313D24 /* Sources */, 54F6A83F195C20C200313D24 /* Frameworks */, 54F6A840195C20C200313D24 /* Resources */, 5435B8C41AD8614F00B805F1 /* Copy Frameworks */, + 28E8257CE249F34272E74DA2 /* [CP] Embed Pods Frameworks */, + 713F939466D9EC6B77F49675 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -542,9 +578,12 @@ isa = PBXNativeTarget; buildConfigurationList = 632F092A1BF1E7FC002431A3 /* Build configuration list for PBXNativeTarget "Cartography-tvOS-tests" */; buildPhases = ( + 23F8E3613FE66A444A4C94A1 /* [CP] Check Pods Manifest.lock */, 632F091E1BF1E7FC002431A3 /* Sources */, 632F091F1BF1E7FC002431A3 /* Frameworks */, 632F09201BF1E7FC002431A3 /* Resources */, + 02D0EEC2C95F444E52A8D1D4 /* [CP] Embed Pods Frameworks */, + B48162A10CC76148734211CF /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -572,6 +611,7 @@ }; 54C96A1B195063CD000CDD27 = { CreatedOnToolsVersion = 6.0; + LastSwiftMigration = 0800; TestTargetID = 54C96A10195063CD000CDD27; }; 54F6A837195C20C100313D24 = { @@ -660,6 +700,144 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 02D0EEC2C95F444E52A8D1D4 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TestPods-Cartography-tvOS-tests/Pods-TestPods-Cartography-tvOS-tests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 23F8E3613FE66A444A4C94A1 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 24028C048E277759E25AE786 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 28E8257CE249F34272E74DA2 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TestPods-Cartography-Mac-Tests/Pods-TestPods-Cartography-Mac-Tests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 713F939466D9EC6B77F49675 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TestPods-Cartography-Mac-Tests/Pods-TestPods-Cartography-Mac-Tests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 8EB90FDED8EA58C4CCBBC95A /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TestPods-Cartography-iOS-Tests/Pods-TestPods-Cartography-iOS-Tests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + B48162A10CC76148734211CF /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TestPods-Cartography-tvOS-tests/Pods-TestPods-Cartography-tvOS-tests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + B6F7D337FFD9973F4083FCD3 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TestPods-Cartography-iOS-Tests/Pods-TestPods-Cartography-iOS-Tests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + DA4D07B720B9F2E815A2DE6C /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 54C96A0C195063CD000CDD27 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -844,8 +1022,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; @@ -891,8 +1071,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; @@ -936,7 +1118,7 @@ PRODUCT_NAME = Cartography; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -959,12 +1141,13 @@ PRODUCT_NAME = Cartography; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Release; }; 54C96A2B195063CD000CDD27 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 007A7C5A4CF651CD9D550547 /* Pods-TestPods-Cartography-iOS-Tests.debug.xcconfig */; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", @@ -978,14 +1161,15 @@ INFOPLIST_FILE = CartographyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; METAL_ENABLE_DEBUG_INFO = YES; - OTHER_SWIFT_FLAGS = "-DTEST"; PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; 54C96A2C195063CD000CDD27 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 125531F897589C40A2E6968E /* Pods-TestPods-Cartography-iOS-Tests.release.xcconfig */; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", @@ -995,10 +1179,10 @@ INFOPLIST_FILE = CartographyTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; METAL_ENABLE_DEBUG_INFO = NO; - OTHER_SWIFT_FLAGS = "-DTEST"; PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -1025,7 +1209,7 @@ PRODUCT_NAME = Cartography; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -1050,12 +1234,13 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Release; }; 54F6A84F195C20C200313D24 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 3C61A3F684FD20F5E1B1F8D1 /* Pods-TestPods-Cartography-Mac-Tests.debug.xcconfig */; buildSettings = { COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -1071,16 +1256,16 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; METAL_ENABLE_DEBUG_INFO = YES; - OTHER_SWIFT_FLAGS = "-DTEST"; PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; 54F6A850195C20C200313D24 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 690415756227F5789FBF9D77 /* Pods-TestPods-Cartography-Mac-Tests.release.xcconfig */; buildSettings = { COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -1093,12 +1278,11 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; METAL_ENABLE_DEBUG_INFO = NO; - OTHER_SWIFT_FLAGS = "-DTEST"; PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -1122,7 +1306,7 @@ PRODUCT_NAME = Cartography; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1150,7 +1334,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1158,6 +1342,7 @@ }; 632F092B1BF1E7FC002431A3 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 45CEEFB5D80398843533851A /* Pods-TestPods-Cartography-tvOS-tests.debug.xcconfig */; buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; GCC_NO_COMMON_BLOCKS = YES; @@ -1167,13 +1352,14 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.robertboehnke.Cartography.Cartography-tvOS-tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Debug; }; 632F092C1BF1E7FC002431A3 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 7D3596ED3F137EB677E57692 /* Pods-TestPods-Cartography-tvOS-tests.release.xcconfig */; buildSettings = { COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -1185,7 +1371,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Release; diff --git a/Cartography.xcworkspace/contents.xcworkspacedata b/Cartography.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..0d068e9 --- /dev/null +++ b/Cartography.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Cartography/Align.swift b/Cartography/Align.swift index cd88372..51f84ca 100644 --- a/Cartography/Align.swift +++ b/Cartography/Align.swift @@ -12,7 +12,7 @@ import UIKit import AppKit #endif -private func makeEqual(attribute: LayoutProxy -> P, first: LayoutProxy, rest: [LayoutProxy]) -> [NSLayoutConstraint] { +private func makeEqual(_ attribute: (LayoutProxy) -> P, first: LayoutProxy, rest: [LayoutProxy]) -> [NSLayoutConstraint] { return rest.reduce([]) { acc, current in current.view.car_translatesAutoresizingMaskIntoConstraints = false @@ -27,7 +27,7 @@ private func makeEqual(attribute: LayoutProxy -> P, first: /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(top first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(top first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.top }, first: first, rest: rest) } @@ -38,7 +38,7 @@ public func align(top first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutCo /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(right first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(right first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.right }, first: first, rest: rest) } @@ -49,7 +49,7 @@ public func align(right first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayout /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(bottom first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(bottom first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.bottom }, first: first, rest: rest) } @@ -60,7 +60,7 @@ public func align(bottom first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayou /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(left first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(left first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.left }, first: first, rest: rest) } @@ -71,7 +71,7 @@ public func align(left first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutC /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(leading first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(leading first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.leading }, first: first, rest: rest) } @@ -82,7 +82,7 @@ public func align(leading first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayo /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(trailing first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(trailing first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.trailing }, first: first, rest: rest) } @@ -93,7 +93,7 @@ public func align(trailing first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLay /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(centerX first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(centerX first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.centerX }, first: first, rest: rest) } @@ -104,7 +104,7 @@ public func align(centerX first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayo /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(centerY first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(centerY first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.centerY }, first: first, rest: rest) } @@ -115,6 +115,6 @@ public func align(centerY first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayo /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func align(baseline first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func align(baseline first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return makeEqual({ $0.baseline }, first: first, rest: rest) } diff --git a/Cartography/Compound.swift b/Cartography/Compound.swift index a7cddeb..f286a87 100644 --- a/Cartography/Compound.swift +++ b/Cartography/Compound.swift @@ -29,7 +29,7 @@ public protocol RelativeCompoundEquality : Compound { } /// /// - returns: An `NSLayoutConstraint`. /// -public func == (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { +@discardableResult public func == (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value) } @@ -39,7 +39,7 @@ public func == (lhs: P, rhs: Expression

) -> [NSL /// `translatesAutoresizingMaskIntoConstraints` set to `false`. /// - parameter rhs: The other property. /// -public func == (lhs: P, rhs: P) -> [NSLayoutConstraint] { +@discardableResult public func == (lhs: P, rhs: P) -> [NSLayoutConstraint] { return lhs.context.addConstraint(lhs, to: rhs) } @@ -55,8 +55,8 @@ public protocol RelativeCompoundInequality : Compound { } /// /// - returns: An `NSLayoutConstraint`. /// -public func <= (lhs: P, rhs: P) -> [NSLayoutConstraint] { - return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.LessThanOrEqual) +@discardableResult public func <= (lhs: P, rhs: P) -> [NSLayoutConstraint] { + return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.lessThanOrEqual) } /// Declares a property greater than or equal to another compound property. @@ -67,8 +67,8 @@ public func <= (lhs: P, rhs: P) -> [NSLayoutConst /// /// - returns: An `NSLayoutConstraint`. /// -public func >= (lhs: P, rhs: P) -> [NSLayoutConstraint] { - return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.GreaterThanOrEqual) +@discardableResult public func >= (lhs: P, rhs: P) -> [NSLayoutConstraint] { + return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.greaterThanOrEqual) } /// Declares a property less than or equal to the result of an expression. @@ -79,8 +79,8 @@ public func >= (lhs: P, rhs: P) -> [NSLayoutConst /// /// - returns: An `NSLayoutConstraint`. /// -public func <= (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { - return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value, relation: NSLayoutRelation.LessThanOrEqual) +@discardableResult public func <= (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { + return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value, relation: NSLayoutRelation.lessThanOrEqual) } /// Declares a property greater than or equal to the result of an expression. @@ -91,8 +91,8 @@ public func <= (lhs: P, rhs: Expression

) -> [N /// /// - returns: An `NSLayoutConstraint`. /// -public func >= (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { - return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value, relation: NSLayoutRelation.GreaterThanOrEqual) +@discardableResult public func >= (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { + return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value, relation: NSLayoutRelation.greaterThanOrEqual) } #if os(iOS) || os(tvOS) @@ -106,7 +106,7 @@ public func >= (lhs: P, rhs: Expression

) -> [N /// - returns: An `NSLayoutConstraint`. /// - public func == (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { + @discardableResult public func == (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { return lhs.context.addConstraint(lhs, to: rhs) } @@ -119,7 +119,7 @@ public func >= (lhs: P, rhs: Expression

) -> [N /// - returns: An `NSLayoutConstraint`. /// - public func == (lhs: P, rhs: Expression) -> NSLayoutConstraint { + @discardableResult public func == (lhs: P, rhs: Expression) -> NSLayoutConstraint { return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0]) } @@ -132,8 +132,8 @@ public func >= (lhs: P, rhs: Expression

) -> [N /// - returns: An `NSLayoutConstraint`. /// - public func >= (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.GreaterThanOrEqual) + @discardableResult public func >= (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.greaterThanOrEqual) } /// Declares a property less than or equal to a layout support. @@ -145,8 +145,8 @@ public func >= (lhs: P, rhs: Expression

) -> [N /// - returns: An `NSLayoutConstraint`. /// - public func <= (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.LessThanOrEqual) + @discardableResult public func <= (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.lessThanOrEqual) } /// Declares a property greater than or equal to the result of a layout support expression. @@ -158,8 +158,8 @@ public func >= (lhs: P, rhs: Expression

) -> [N /// - returns: An `NSLayoutConstraint`. /// - public func >= (lhs: P, rhs: Expression) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.GreaterThanOrEqual) + @discardableResult public func >= (lhs: P, rhs: Expression) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.greaterThanOrEqual) } /// Declares a property less than or equal to the result of a layout support expression. @@ -171,8 +171,8 @@ public func >= (lhs: P, rhs: Expression

) -> [N /// - returns: An `NSLayoutConstraint`. /// - public func <= (lhs: P, rhs: Expression) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.LessThanOrEqual) + @discardableResult public func <= (lhs: P, rhs: Expression) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.lessThanOrEqual) } #endif diff --git a/Cartography/Constrain.swift b/Cartography/Constrain.swift index 29103d1..c1b612b 100644 --- a/Cartography/Constrain.swift +++ b/Cartography/Constrain.swift @@ -15,7 +15,7 @@ import Foundation /// replaced. /// - parameter block: A block that declares the layout for `view`. /// -public func constrain(view: View, replace group: ConstraintGroup = ConstraintGroup(), @noescape block: LayoutProxy -> ()) -> ConstraintGroup { +@discardableResult public func constrain(_ view: View, replace group: ConstraintGroup = ConstraintGroup(), block: (LayoutProxy) -> ()) -> ConstraintGroup { let context = Context() block(LayoutProxy(context, view)) group.replaceConstraints(context.constraints) @@ -31,7 +31,7 @@ public func constrain(view: View, replace group: ConstraintGroup = ConstraintGro /// replaced. /// - parameter block: A block that declares the layout for the views. /// -public func constrain(view1: View, _ view2: View, replace group: ConstraintGroup = ConstraintGroup(), @noescape block: (LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { +@discardableResult public func constrain(_ view1: View, _ view2: View, replace group: ConstraintGroup = ConstraintGroup(), block: (LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { let context = Context() block(LayoutProxy(context, view1), LayoutProxy(context, view2)) group.replaceConstraints(context.constraints) @@ -48,7 +48,7 @@ public func constrain(view1: View, _ view2: View, replace group: ConstraintGroup /// replaced. /// - parameter block: A block that declares the layout for the views. /// -public func constrain(view1: View, _ view2: View, _ view3: View, replace group: ConstraintGroup = ConstraintGroup(), @noescape block: (LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { +@discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, replace group: ConstraintGroup = ConstraintGroup(), block: (LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { let context = Context() block(LayoutProxy(context, view1), LayoutProxy(context, view2), LayoutProxy(context, view3)) group.replaceConstraints(context.constraints) @@ -66,7 +66,7 @@ public func constrain(view1: View, _ view2: View, _ view3: View, replace group: /// replaced. /// - parameter block: A block that declares the layout for the views. /// -public func constrain(view1: View, _ view2: View, _ view3: View, _ view4: View, replace group: ConstraintGroup = ConstraintGroup(), @noescape block: (LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { +@discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, _ view4: View, replace group: ConstraintGroup = ConstraintGroup(), block: (LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { let context = Context() block(LayoutProxy(context, view1), LayoutProxy(context, view2), LayoutProxy(context, view3), LayoutProxy(context, view4)) group.replaceConstraints(context.constraints) @@ -85,7 +85,7 @@ public func constrain(view1: View, _ view2: View, _ view3: View, _ view4: View, /// replaced. /// - parameter block: A block that declares the layout for the views. /// -public func constrain(view1: View, _ view2: View, _ view3: View, _ view4: View, _ view5: View, replace group: ConstraintGroup = ConstraintGroup(), @noescape block: (LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { +@discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, _ view4: View, _ view5: View, replace group: ConstraintGroup = ConstraintGroup(), block: (LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { let context = Context() block(LayoutProxy(context, view1), LayoutProxy(context, view2), LayoutProxy(context, view3), LayoutProxy(context, view4), LayoutProxy(context, view5)) group.replaceConstraints(context.constraints) @@ -100,7 +100,7 @@ public func constrain(view1: View, _ view2: View, _ view3: View, _ view4: View, /// replaced. /// - parameter block: A block that declares the layout for `views`. /// -public func constrain(views: [View], replace group: ConstraintGroup = ConstraintGroup(), @noescape block: ([LayoutProxy]) -> ()) -> ConstraintGroup { +@discardableResult public func constrain(_ views: [View], replace group: ConstraintGroup = ConstraintGroup(), block: ([LayoutProxy]) -> ()) -> ConstraintGroup { let context = Context() block(views.map({ LayoutProxy(context, $0) })) group.replaceConstraints(context.constraints) @@ -115,10 +115,16 @@ public func constrain(views: [View], replace group: ConstraintGroup = Constraint /// replaced. /// - parameter block: A block that declares the layout for `views`. /// -public func constrain(views: [T: View], replace group: ConstraintGroup = ConstraintGroup(), @noescape block: ([T : LayoutProxy] -> ())) -> ConstraintGroup { +@discardableResult public func constrain(_ views: [T: View], replace group: ConstraintGroup = ConstraintGroup(), block: (([T : LayoutProxy]) -> ())) -> ConstraintGroup { let context = Context() let proxies = views.map { ($0, LayoutProxy(context, $1)) } - block(Dictionary(proxies)) + var dict = [T:LayoutProxy]() + + proxies.forEach { + dict[$0.0] = $0.1 + } + + block(dict) group.replaceConstraints(context.constraints) return group @@ -128,6 +134,6 @@ public func constrain(views: [T: View], replace group: ConstraintGr /// /// - parameter clear: The `ConstraintGroup` whose constraints should be removed. /// -public func constrain(clear group: ConstraintGroup) { +@discardableResult public func constrain(clear group: ConstraintGroup) { group.replaceConstraints([]) } diff --git a/Cartography/ConstraintGroup.swift b/Cartography/ConstraintGroup.swift index 8872bd9..e1fcf6f 100644 --- a/Cartography/ConstraintGroup.swift +++ b/Cartography/ConstraintGroup.swift @@ -11,17 +11,17 @@ import Foundation public class ConstraintGroup { private var constraints: [Constraint] = [] - @available(OSX, introduced=10.10) - @available(iOS, introduced=8.0) + @available(OSX, introduced: 10.10) + @available(iOS, introduced: 8.0) public var active: Bool { get { return constraints - .map { $0.layoutConstraint.active } + .map { $0.layoutConstraint.isActive } .reduce(true) { $0 && $1 } } set { for constraint in constraints { - constraint.layoutConstraint.active = newValue + constraint.layoutConstraint.isActive = newValue } } } @@ -30,7 +30,7 @@ public class ConstraintGroup { } - internal func replaceConstraints(constraints: [Constraint]) { + internal func replaceConstraints(_ constraints: [Constraint]) { for constraint in self.constraints { constraint.uninstall() } diff --git a/Cartography/Context.swift b/Cartography/Context.swift index b2705b1..6420ff0 100644 --- a/Cartography/Context.swift +++ b/Cartography/Context.swift @@ -17,7 +17,7 @@ public class Context { #if os(iOS) || os(tvOS) - internal func addConstraint(from: Property, to: LayoutSupport, coefficients: Coefficients = Coefficients(), relation: NSLayoutRelation = .Equal) -> NSLayoutConstraint { + internal func addConstraint(_ from: Property, to: LayoutSupport, coefficients: Coefficients = Coefficients(), relation: NSLayoutRelation = .equal) -> NSLayoutConstraint { from.view.car_translatesAutoresizingMaskIntoConstraints = false let layoutConstraint = NSLayoutConstraint(item: from.view, @@ -39,14 +39,15 @@ public class Context { #endif - internal func addConstraint(from: Property, to: Property? = nil, coefficients: Coefficients = Coefficients(), relation: NSLayoutRelation = .Equal) -> NSLayoutConstraint { + internal func addConstraint(_ from: Property, to: Property? = nil, coefficients: Coefficients = Coefficients(), relation: NSLayoutRelation = .equal) -> NSLayoutConstraint { + from.view.car_translatesAutoresizingMaskIntoConstraints = false let layoutConstraint = NSLayoutConstraint(item: from.view, attribute: from.attribute, relatedBy: relation, toItem: to?.view, - attribute: to?.attribute ?? .NotAnAttribute, + attribute: to?.attribute ?? .notAnAttribute, multiplier: CGFloat(coefficients.multiplier), constant: CGFloat(coefficients.constant)) @@ -63,13 +64,13 @@ public class Context { return layoutConstraint } - internal func addConstraint(from: Compound, coefficients: [Coefficients]? = nil, to: Compound? = nil, relation: NSLayoutRelation = NSLayoutRelation.Equal) -> [NSLayoutConstraint] { + internal func addConstraint(_ from: Compound, coefficients: [Coefficients]? = nil, to: Compound? = nil, relation: NSLayoutRelation = NSLayoutRelation.equal) -> [NSLayoutConstraint] { var results: [NSLayoutConstraint] = [] for i in 0.. NSLayoutConstraint) -> [NSLayoutConstraint] { +@discardableResult private func reduce(_ first: LayoutProxy, rest: [LayoutProxy], combine: (LayoutProxy, LayoutProxy) -> NSLayoutConstraint) -> [NSLayoutConstraint] { rest.last?.view.car_translatesAutoresizingMaskIntoConstraints = false return rest.reduce(([], first)) { (acc, current) -> Accumulator in @@ -34,7 +34,7 @@ private func reduce(first: LayoutProxy, rest: [LayoutProxy], combine: (LayoutPro /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func distribute(by amount: CGFloat, horizontally first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func distribute(by amount: CGFloat, horizontally first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return reduce(first, rest: rest) { $0.trailing == $1.leading - amount } } @@ -48,7 +48,7 @@ public func distribute(by amount: CGFloat, horizontally first: LayoutProxy, _ re /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func distribute(by amount: CGFloat, leftToRight first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func distribute(by amount: CGFloat, leftToRight first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return reduce(first, rest: rest) { $0.right == $1.left - amount } } @@ -62,6 +62,6 @@ public func distribute(by amount: CGFloat, leftToRight first: LayoutProxy, _ res /// /// - returns: An array of `NSLayoutConstraint` instances. /// -public func distribute(by amount: CGFloat, vertically first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { +@discardableResult public func distribute(by amount: CGFloat, vertically first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { return reduce(first, rest: rest) { $0.bottom == $1.top - amount } } diff --git a/Cartography/Edges.swift b/Cartography/Edges.swift index e6e44a7..7216ec6 100644 --- a/Cartography/Edges.swift +++ b/Cartography/Edges.swift @@ -29,7 +29,7 @@ public struct Edges: Compound, RelativeCompoundEquality, RelativeCompoundInequal /// /// - returns: A new expression with the inset edges. /// -public func inset(edges: Edges, _ all: CGFloat) -> Expression { +public func inset(_ edges: Edges, _ all: CGFloat) -> Expression { return inset(edges, all, all, all, all) } @@ -43,7 +43,7 @@ public func inset(edges: Edges, _ all: CGFloat) -> Expression { /// /// - returns: A new expression with the inset edges. /// -public func inset(edges: Edges, _ horizontal: CGFloat, _ vertical: CGFloat) -> Expression { +public func inset(_ edges: Edges, _ horizontal: CGFloat, _ vertical: CGFloat) -> Expression { return inset(edges, vertical, horizontal, vertical, horizontal) } @@ -57,7 +57,7 @@ public func inset(edges: Edges, _ horizontal: CGFloat, _ vertical: CGFloat) -> E /// /// - returns: A new expression with the inset edges. /// -public func inset(edges: Edges, _ top: CGFloat, _ leading: CGFloat, _ bottom: CGFloat, _ trailing: CGFloat) -> Expression { +public func inset(_ edges: Edges, _ top: CGFloat, _ leading: CGFloat, _ bottom: CGFloat, _ trailing: CGFloat) -> Expression { return Expression(edges, [ Coefficients(1, top), Coefficients(1, leading), @@ -74,7 +74,7 @@ public func inset(edges: Edges, _ top: CGFloat, _ leading: CGFloat, _ bottom: CG /// /// - returns: A new expression with the inset edges. /// -public func inset(edges: Edges, _ insets: UIEdgeInsets) -> Expression { +public func inset(_ edges: Edges, _ insets: UIEdgeInsets) -> Expression { return inset(edges, insets.top, insets.left, insets.bottom, insets.right) } #endif diff --git a/Cartography/LayoutProxy.swift b/Cartography/LayoutProxy.swift index 78237e6..cb95892 100644 --- a/Cartography/LayoutProxy.swift +++ b/Cartography/LayoutProxy.swift @@ -11,167 +11,167 @@ import Foundation public struct LayoutProxy { /// The width of the view. public var width: Dimension { - return Dimension(context, view, .Width) + return Dimension(context, view, .width) } /// The height of the view. public var height: Dimension { - return Dimension(context, view, .Height) + return Dimension(context, view, .height) } /// The size of the view. This property affects both `width` and `height`. public var size: Size { return Size(context, [ - Dimension(context, view, .Width), - Dimension(context, view, .Height) + Dimension(context, view, .width), + Dimension(context, view, .height) ]) } /// The top edge of the view. public var top: Edge { - return Edge(context, view, .Top) + return Edge(context, view, .top) } /// The right edge of the view. public var right: Edge { - return Edge(context, view, .Right) + return Edge(context, view, .right) } /// The bottom edge of the view. public var bottom: Edge { - return Edge(context, view, .Bottom) + return Edge(context, view, .bottom) } /// The left edge of the view. public var left: Edge { - return Edge(context, view, .Left) + return Edge(context, view, .left) } /// All edges of the view. This property affects `top`, `bottom`, `leading` /// and `trailing`. public var edges: Edges { return Edges(context, [ - Edge(context, view, .Top), - Edge(context, view, .Leading), - Edge(context, view, .Bottom), - Edge(context, view, .Trailing) + Edge(context, view, .top), + Edge(context, view, .leading), + Edge(context, view, .bottom), + Edge(context, view, .trailing) ]) } /// The leading edge of the view. public var leading: Edge { - return Edge(context, view, .Leading) + return Edge(context, view, .leading) } /// The trailing edge of the view. public var trailing: Edge { - return Edge(context, view, .Trailing) + return Edge(context, view, .trailing) } /// The horizontal center of the view. public var centerX: Edge { - return Edge(context, view, .CenterX) + return Edge(context, view, .centerX) } /// The vertical center of the view. public var centerY: Edge { - return Edge(context, view, .CenterY) + return Edge(context, view, .centerY) } /// The center point of the view. This property affects `centerX` and /// `centerY`. public var center: Point { return Point(context, [ - Edge(context, view, .CenterX), - Edge(context, view, .CenterY) + Edge(context, view, .centerX), + Edge(context, view, .centerY) ]) } /// The baseline of the view. public var baseline: Edge { - return Edge(context, view, .LastBaseline) + return Edge(context, view, .lastBaseline) } /// The last baseline of the view. public var lastBaseline: Edge { - return Edge(context, view, .LastBaseline) + return Edge(context, view, .lastBaseline) } #if os(iOS) || os(tvOS) /// The first baseline of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var firstBaseline: Edge { - return Edge(context, view, .FirstBaseline) + return Edge(context, view, .firstBaseline) } /// All edges of the view with their respective margins. This property /// affects `topMargin`, `bottomMargin`, `leadingMargin` and /// `trailingMargin`. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var edgesWithinMargins: Edges { return Edges(context, [ - Edge(context, view, .TopMargin), - Edge(context, view, .LeadingMargin), - Edge(context, view, .BottomMargin), - Edge(context, view, .TrailingMargin) + Edge(context, view, .topMargin), + Edge(context, view, .leadingMargin), + Edge(context, view, .bottomMargin), + Edge(context, view, .trailingMargin) ]) } /// The left margin of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var leftMargin: Edge { - return Edge(context, view, .LeftMargin) + return Edge(context, view, .leftMargin) } /// The right margin of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var rightMargin: Edge { - return Edge(context, view, .RightMargin) + return Edge(context, view, .rightMargin) } /// The top margin of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var topMargin: Edge { - return Edge(context, view, .TopMargin) + return Edge(context, view, .topMargin) } /// The bottom margin of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var bottomMargin: Edge { - return Edge(context, view, .BottomMargin) + return Edge(context, view, .bottomMargin) } /// The leading margin of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var leadingMargin: Edge { - return Edge(context, view, .LeadingMargin) + return Edge(context, view, .leadingMargin) } /// The trailing margin of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var trailingMargin: Edge { - return Edge(context, view, .TrailingMargin) + return Edge(context, view, .trailingMargin) } /// The horizontal center within the margins of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var centerXWithinMargins: Edge { - return Edge(context, view, .CenterXWithinMargins) + return Edge(context, view, .centerXWithinMargins) } /// The vertical center within the margins of the view. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var centerYWithinMargins: Edge { - return Edge(context, view, .CenterYWithinMargins) + return Edge(context, view, .centerYWithinMargins) } /// The center point within the margins of the view. This property affects /// `centerXWithinMargins` and `centerYWithinMargins`. iOS exclusive. - @available(iOS, introduced=8.0) + @available(iOS, introduced: 8.0) public var centerWithinMargins: Point { return Point(context, [ - Edge(context, view, .CenterXWithinMargins), - Edge(context, view, .CenterYWithinMargins) + Edge(context, view, .centerXWithinMargins), + Edge(context, view, .centerYWithinMargins) ]) } #endif diff --git a/Cartography/LayoutSupport.swift b/Cartography/LayoutSupport.swift index c35089d..bb9b160 100644 --- a/Cartography/LayoutSupport.swift +++ b/Cartography/LayoutSupport.swift @@ -20,13 +20,13 @@ import Foundation public var topLayoutGuideCartography : LayoutSupport { get { - return LayoutSupport(layoutGuide: self.topLayoutGuide, attribute: .Bottom) + return LayoutSupport(layoutGuide: self.topLayoutGuide, attribute: .bottom) } } public var bottomLayoutGuideCartography : LayoutSupport { get { - return LayoutSupport(layoutGuide: self.bottomLayoutGuide, attribute: .Top) + return LayoutSupport(layoutGuide: self.bottomLayoutGuide, attribute: .top) } } } diff --git a/Cartography/Priority.swift b/Cartography/Priority.swift index 72fece0..6bdcbaa 100644 --- a/Cartography/Priority.swift +++ b/Cartography/Priority.swift @@ -16,7 +16,11 @@ import AppKit public typealias LayoutPriority = NSLayoutPriority #endif -infix operator ~ { } +precedencegroup CarthographyPriorityPrecedence { + lowerThan: ComparisonPrecedence +} + +infix operator ~: CarthographyPriorityPrecedence /// Sets the priority for a constraint. /// @@ -25,7 +29,7 @@ infix operator ~ { } /// /// - returns: The same constraint with its priority updated. /// -public func ~ (lhs: NSLayoutConstraint, rhs: LayoutPriority) -> NSLayoutConstraint { +@discardableResult public func ~ (lhs: NSLayoutConstraint, rhs: LayoutPriority) -> NSLayoutConstraint { lhs.priority = rhs return lhs @@ -38,7 +42,7 @@ public func ~ (lhs: NSLayoutConstraint, rhs: LayoutPriority) -> NSLayoutConstrai /// /// - returns: The same constraints with their priorities updated. /// -public func ~ (lhs: [NSLayoutConstraint], rhs: LayoutPriority) -> [NSLayoutConstraint] { +@discardableResult public func ~ (lhs: [NSLayoutConstraint], rhs: LayoutPriority) -> [NSLayoutConstraint] { return lhs.map { $0 ~ rhs } diff --git a/Cartography/Property.swift b/Cartography/Property.swift index 8021ca8..9d1c14a 100644 --- a/Cartography/Property.swift +++ b/Cartography/Property.swift @@ -32,7 +32,7 @@ public protocol NumericalEquality : Property { } /// /// - returns: An `NSLayoutConstraint`. /// -public func == (lhs: NumericalEquality, rhs: CGFloat) -> NSLayoutConstraint { +@discardableResult public func == (lhs: NumericalEquality, rhs: CGFloat) -> NSLayoutConstraint { return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs)) } @@ -48,8 +48,8 @@ public protocol RelativeEquality : Property { } /// /// - returns: An `NSLayoutConstraint`. /// -public func == (lhs: P, rhs: Expression

) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients[0], to: rhs.value) +@discardableResult public func == (lhs: P, rhs: Expression

) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0]) } /// Declares a property equal to another property. @@ -58,7 +58,7 @@ public func == (lhs: P, rhs: Expression

) -> NSLayoutCons /// `translatesAutoresizingMaskIntoConstraints` set to `false`. /// - parameter rhs: The other property. /// -public func == (lhs: P, rhs: P) -> NSLayoutConstraint { +@discardableResult public func == (lhs: P, rhs: P) -> NSLayoutConstraint { return lhs.context.addConstraint(lhs, to: rhs) } @@ -76,8 +76,8 @@ public protocol NumericalInequality : Property { } /// /// - returns: An `NSLayoutConstraint`. /// -public func <= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs), relation: NSLayoutRelation.LessThanOrEqual) +@discardableResult public func <= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs), relation: NSLayoutRelation.lessThanOrEqual) } /// Declares a property greater than or equal to a numerical constant. @@ -88,8 +88,8 @@ public func <= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint { /// /// - returns: An `NSLayoutConstraint`. /// -public func >= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs), relation: NSLayoutRelation.GreaterThanOrEqual) +@discardableResult public func >= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs), relation: NSLayoutRelation.greaterThanOrEqual) } /// Properties conforming to this protocol can use the `<=` and `>=` operators @@ -104,8 +104,8 @@ public protocol RelativeInequality : Property { } /// /// - returns: An `NSLayoutConstraint`. /// -public func <= (lhs: P, rhs: P) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.LessThanOrEqual) +@discardableResult public func <= (lhs: P, rhs: P) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.lessThanOrEqual) } /// Declares a property greater than or equal to another property. @@ -116,8 +116,8 @@ public func <= (lhs: P, rhs: P) -> NSLayoutConstraint { /// /// - returns: An `NSLayoutConstraint`. /// -public func >= (lhs: P, rhs: P) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.GreaterThanOrEqual) +@discardableResult public func >= (lhs: P, rhs: P) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.greaterThanOrEqual) } /// Declares a property less than or equal to the result of an expression. @@ -128,8 +128,8 @@ public func >= (lhs: P, rhs: P) -> NSLayoutConstraint { /// /// - returns: An `NSLayoutConstraint`. /// -public func <= (lhs: P, rhs: Expression

) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients[0], to: rhs.value, relation: NSLayoutRelation.LessThanOrEqual) +@discardableResult public func <= (lhs: P, rhs: Expression

) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.lessThanOrEqual) } /// Declares a property greater than or equal to the result of an expression. @@ -140,8 +140,8 @@ public func <= (lhs: P, rhs: Expression

) -> NSLayoutCo /// /// - returns: An `NSLayoutConstraint`. /// -public func >= (lhs: P, rhs: Expression

) -> NSLayoutConstraint { - return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients[0], to: rhs.value, relation: NSLayoutRelation.GreaterThanOrEqual) +@discardableResult public func >= (lhs: P, rhs: Expression

) -> NSLayoutConstraint { + return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.greaterThanOrEqual) } // MARK: Addition diff --git a/Cartography/ViewUtils.swift b/Cartography/ViewUtils.swift index a1674cd..edd67d2 100644 --- a/Cartography/ViewUtils.swift +++ b/Cartography/ViewUtils.swift @@ -12,7 +12,7 @@ import UIKit import AppKit #endif -internal func closestCommonAncestor(a: View, b: View) -> View? { +internal func closestCommonAncestor(_ a: View, b: View) -> View? { let (aSuper, bSuper) = (a.superview, b.superview) if a === b { return a } @@ -31,13 +31,13 @@ internal func closestCommonAncestor(a: View, b: View) -> View? { } } - return .None + return .none } -private func ancestors(v: View) -> AnySequence { - return AnySequence { () -> AnyGenerator in +private func ancestors(_ v: View) -> AnySequence { + return AnySequence { () -> AnyIterator in var view: View? = v - return AnyGenerator { + return AnyIterator { let current = view view = view?.superview return current diff --git a/CartographyTests/AlignSpec.swift b/CartographyTests/AlignSpec.swift index adad1da..231b559 100644 --- a/CartographyTests/AlignSpec.swift +++ b/CartographyTests/AlignSpec.swift @@ -11,15 +11,15 @@ class AlignSpec: QuickSpec { var viewC: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 400, 400)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - viewA = TestView(frame: CGRectZero) + viewA = TestView(frame: CGRect.zero) window.addSubview(viewA) - viewB = TestView(frame: CGRectZero) + viewB = TestView(frame: CGRect.zero) window.addSubview(viewB) - viewC = TestView(frame: CGRectZero) + viewC = TestView(frame: CGRect.zero) window.addSubview(viewC) constrain(viewA) { view in diff --git a/CartographyTests/ConstraintGroupSpec.swift b/CartographyTests/ConstraintGroupSpec.swift index e5745c4..eb467e3 100644 --- a/CartographyTests/ConstraintGroupSpec.swift +++ b/CartographyTests/ConstraintGroupSpec.swift @@ -9,9 +9,9 @@ class ConstraintGroupSpec: QuickSpec { var view1: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 400, 400)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - view1 = TestView(frame: CGRectZero) + view1 = TestView(frame: CGRect.zero) window.addSubview(view1) } @@ -57,7 +57,7 @@ class ConstraintGroupSpec: QuickSpec { var view2: TestView! beforeEach { - view2 = TestView(frame: CGRectZero) + view2 = TestView(frame: CGRect.zero) window.addSubview(view2) constrain(view1, view2) { view1, view2 in diff --git a/CartographyTests/DimensionSpec.swift b/CartographyTests/DimensionSpec.swift index fb86a8c..1dfe95c 100644 --- a/CartographyTests/DimensionSpec.swift +++ b/CartographyTests/DimensionSpec.swift @@ -9,9 +9,9 @@ class DimensionSpec: QuickSpec { var view: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 400, 400)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - view = TestView(frame: CGRectZero) + view = TestView(frame: CGRect.zero) window.addSubview(view) } diff --git a/CartographyTests/DistributeSpec.swift b/CartographyTests/DistributeSpec.swift index c13e382..4323503 100644 --- a/CartographyTests/DistributeSpec.swift +++ b/CartographyTests/DistributeSpec.swift @@ -11,15 +11,15 @@ class DistributeSpec: QuickSpec { var viewC: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 400, 400)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - viewA = TestView(frame: CGRectZero) + viewA = TestView(frame: CGRect.zero) window.addSubview(viewA) - viewB = TestView(frame: CGRectZero) + viewB = TestView(frame: CGRect.zero) window.addSubview(viewB) - viewC = TestView(frame: CGRectZero) + viewC = TestView(frame: CGRect.zero) window.addSubview(viewC) constrain(viewA, viewB, viewC) { viewA, viewB, viewC in diff --git a/CartographyTests/EdgeSpec.swift b/CartographyTests/EdgeSpec.swift index 22ca811..ab58d1a 100644 --- a/CartographyTests/EdgeSpec.swift +++ b/CartographyTests/EdgeSpec.swift @@ -9,9 +9,9 @@ class EdgeSpec: QuickSpec { var view: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 400, 400)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - view = TestView(frame: CGRectZero) + view = TestView(frame: CGRect.zero) window.addSubview(view) constrain(view) { view in diff --git a/CartographyTests/EdgesSpec.swift b/CartographyTests/EdgesSpec.swift index 2f26a6c..6f32d06 100644 --- a/CartographyTests/EdgesSpec.swift +++ b/CartographyTests/EdgesSpec.swift @@ -9,9 +9,9 @@ class EdgesSpec: QuickSpec { var view: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 400, 400)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - view = TestView(frame: CGRectZero) + view = TestView(frame: CGRect.zero) window.addSubview(view) } @@ -48,7 +48,7 @@ class EdgesSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(20, 20, 360, 360))) + expect(view.frame).to(equal(CGRect(x: 20, y: 20, width: 360, height: 360))) } it("should inset the horizontal and vertical edge individually") { @@ -58,7 +58,7 @@ class EdgesSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(20, 30, 360, 340))) + expect(view.frame).to(equal(CGRect(x: 20, y: 30, width: 360, height: 340))) } it("should inset all edges individually") { @@ -68,7 +68,7 @@ class EdgesSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(20, 10, 340, 360))) + expect(view.frame).to(equal(CGRect(x: 20, y: 10, width: 340, height: 360))) } } @@ -86,7 +86,7 @@ class EdgesSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(20, 10, 340, 360))) + expect(view.frame).to(equal(CGRect(x: 20, y: 10, width: 340, height: 360))) } } } @@ -100,7 +100,7 @@ class EdgesSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(20, 10, 340, 360))) + expect(view.frame).to(equal(CGRect(x: 20, y: 10, width: 340, height: 360))) } } #endif diff --git a/CartographyTests/LayoutSupportSpec.swift b/CartographyTests/LayoutSupportSpec.swift index 3ad1168..c8447a8 100644 --- a/CartographyTests/LayoutSupportSpec.swift +++ b/CartographyTests/LayoutSupportSpec.swift @@ -13,9 +13,9 @@ class LayoutSupportSpec: QuickSpec { var tabBarController: UITabBarController! beforeEach { - window = TestWindow(frame: CGRectMake(0,0,400,400)) + window = TestWindow(frame: CGRect(x: 0,y: 0, width: 400, height: 400)) - view = TestView(frame: CGRectZero) + view = TestView(frame: CGRect.zero) viewController = UIViewController() viewController.view.addSubview(view) @@ -48,7 +48,7 @@ class LayoutSupportSpec: QuickSpec { } viewController.view.layoutIfNeeded() - expect(view.convertRect(view.bounds, toView: window).minY).to(equal(viewController.topLayoutGuide.length)) + expect(view.convert(view.bounds, to: window).minY).to(equal(viewController.topLayoutGuide.length)) } it("should support relative inequalities") { @@ -59,7 +59,7 @@ class LayoutSupportSpec: QuickSpec { viewController.view.layoutIfNeeded() - expect(view.convertRect(view.bounds, toView: window).minY).to(equal(viewController.topLayoutGuide.length)) + expect(view.convert(view.bounds, to: window).minY).to(equal(viewController.topLayoutGuide.length)) } it("should support addition") { @@ -69,7 +69,7 @@ class LayoutSupportSpec: QuickSpec { viewController.view.layoutIfNeeded() - expect(view.convertRect(view.bounds, toView: window).minY).to(equal(100 + viewController.topLayoutGuide.length)) + expect(view.convert(view.bounds, to: window).minY).to(equal(100 + viewController.topLayoutGuide.length)) } it("should support subtraction") { @@ -79,7 +79,7 @@ class LayoutSupportSpec: QuickSpec { viewController.view.layoutIfNeeded() - expect(view.convertRect(view.bounds, toView: window).minY).to(equal(-100 - viewController.topLayoutGuide.length)) + expect(view.convert(view.bounds, to: window).minY).to(equal(-100 - viewController.topLayoutGuide.length)) } } @@ -90,7 +90,7 @@ class LayoutSupportSpec: QuickSpec { } viewController.view.layoutIfNeeded() - expect(view.convertRect(view.bounds, toView: window).maxY).to(equal(window.bounds.maxY - viewController.bottomLayoutGuide.length)) + expect(view.convert(view.bounds, to: window).maxY).to(equal(window.bounds.maxY - viewController.bottomLayoutGuide.length)) } it("should support relative inequalities") { @@ -101,7 +101,7 @@ class LayoutSupportSpec: QuickSpec { viewController.view.layoutIfNeeded() - expect(view.convertRect(view.bounds, toView: window).maxY).to(equal(window.bounds.maxY - viewController.bottomLayoutGuide.length)) + expect(view.convert(view.bounds, to: window).maxY).to(equal(window.bounds.maxY - viewController.bottomLayoutGuide.length)) } it("should support addition") { @@ -111,7 +111,7 @@ class LayoutSupportSpec: QuickSpec { viewController.view.layoutIfNeeded() - expect(view.convertRect(view.bounds, toView: window).maxY).to(equal(100 + window.bounds.maxY - viewController.bottomLayoutGuide.length)) + expect(view.convert(view.bounds, to: window).maxY).to(equal(100 + window.bounds.maxY - viewController.bottomLayoutGuide.length)) } it("should support subtraction") { @@ -121,7 +121,7 @@ class LayoutSupportSpec: QuickSpec { viewController.view.layoutIfNeeded() - expect(view.convertRect(view.bounds, toView: window).maxY).to(equal((window.bounds.maxY - 100) - viewController.bottomLayoutGuide.length)) + expect(view.convert(view.bounds, to: window).maxY).to(equal((window.bounds.maxY - 100) - viewController.bottomLayoutGuide.length)) } } diff --git a/CartographyTests/Matchers.swift b/CartographyTests/Matchers.swift index f2cc903..512fc2b 100644 --- a/CartographyTests/Matchers.swift +++ b/CartographyTests/Matchers.swift @@ -1,11 +1,12 @@ import Cartography +import Quick import Nimble public func translateAutoresizingMasksToConstraints() -> NonNilMatcherFunc { return NonNilMatcherFunc { actualExpression, failureMessage in let view = try! actualExpression.evaluate() - failureMessage.expected = "expected \(view?.description ?? view)" + failureMessage.expected = "expected \(view?.description)" failureMessage.actualValue = nil failureMessage.postfixMessage = "translate autoresizing masks to constraints" diff --git a/CartographyTests/MemoryLeakSpec.swift b/CartographyTests/MemoryLeakSpec.swift index 1491fb6..2edaafe 100644 --- a/CartographyTests/MemoryLeakSpec.swift +++ b/CartographyTests/MemoryLeakSpec.swift @@ -7,17 +7,17 @@ class MemoryLeakSpec: QuickSpec { override func spec() { describe("constrain") { it("should not leak memory") { - weak var weak_superview: View? = .None - weak var weak_viewA: View? = .None - weak var weak_viewB: View? = .None + weak var weak_superview: View? = .none + weak var weak_viewA: View? = .none + weak var weak_viewB: View? = .none autoreleasepool { - let superview = View(frame: CGRectMake(0, 0, 400, 400)) + let superview = View(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - let viewA: TestView = TestView(frame: CGRectMake(0, 0, 200, 200)) + let viewA: TestView = TestView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) superview.addSubview(viewA) - let viewB: TestView = TestView(frame: CGRectMake(0, 0, 200, 200)) + let viewB: TestView = TestView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) superview.addSubview(viewB) weak_superview = superview diff --git a/CartographyTests/PointSpec.swift b/CartographyTests/PointSpec.swift index 0cd1599..9d497e6 100644 --- a/CartographyTests/PointSpec.swift +++ b/CartographyTests/PointSpec.swift @@ -9,9 +9,9 @@ class PointSpec: QuickSpec { var view: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 400, 400)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - view = TestView(frame: CGRectZero) + view = TestView(frame: CGRect.zero) window.addSubview(view) constrain(view) { view in @@ -28,7 +28,7 @@ class PointSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(100, 100, 200, 200))) + expect(view.frame).to(equal(CGRect(x: 100, y: 100, width: 200, height: 200))) } it("should support relative inequalities") { @@ -39,7 +39,7 @@ class PointSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(100, 100, 200, 200))) + expect(view.frame).to(equal(CGRect(x: 100, y: 100, width: 200, height: 200))) } } @@ -57,7 +57,7 @@ class PointSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(110, 110, 200, 200))) + expect(view.frame).to(equal(CGRect(x: 110, y: 110, width: 200, height: 200))) } it("should support relative inequalities") { @@ -68,7 +68,7 @@ class PointSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame).to(equal(CGRectMake(110, 110, 200, 200))) + expect(view.frame).to(equal(CGRect(x: 110, y: 110, width: 200, height: 200))) } } } diff --git a/CartographyTests/PrioritySpec.swift b/CartographyTests/PrioritySpec.swift index 0bb56b6..22708c6 100644 --- a/CartographyTests/PrioritySpec.swift +++ b/CartographyTests/PrioritySpec.swift @@ -9,17 +9,18 @@ class PrioritySpec: QuickSpec { var view: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 200, 200)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) - view = TestView(frame: CGRectZero) + view = TestView(frame: CGRect.zero) window.addSubview(view) } it("should operate on a single constraint") { var constraint: NSLayoutConstraint! - constrain(view) { view in - constraint = (view.width == 200 ~ 100) + constrain(view) { (view: LayoutProxy) in + constraint = view.width == 200 + constraint ~ 100 } expect(constraint.priority).to(equal(100)) diff --git a/CartographyTests/SizeSpec.swift b/CartographyTests/SizeSpec.swift index 8d5d3f1..a71d7aa 100644 --- a/CartographyTests/SizeSpec.swift +++ b/CartographyTests/SizeSpec.swift @@ -9,9 +9,9 @@ class SizeSpec: QuickSpec { var view: TestView! beforeEach { - window = TestWindow(frame: CGRectMake(0, 0, 400, 400)) + window = TestWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) - view = TestView(frame: CGRectZero) + view = TestView(frame: CGRect.zero) window.addSubview(view) } @@ -23,7 +23,7 @@ class SizeSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame.size).to(equal(CGSizeMake(400, 400))) + expect(view.frame.size).to(equal(CGSize(width: 400, height: 400))) } it("should support relative inequalities") { @@ -34,7 +34,7 @@ class SizeSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame.size).to(equal(CGSizeMake(400, 400))) + expect(view.frame.size).to(equal(CGSize(width: 400, height: 400))) } it("should support multiplication") { @@ -44,7 +44,7 @@ class SizeSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame.size).to(equal(CGSizeMake(800, 800))) + expect(view.frame.size).to(equal(CGSize(width: 800, height: 800))) } it("should support division") { @@ -54,7 +54,7 @@ class SizeSpec: QuickSpec { window.layoutIfNeeded() - expect(view.frame.size).to(equal(CGSizeMake(200, 200))) + expect(view.frame.size).to(equal(CGSize(width: 200, height: 200))) } } } diff --git a/CartographyTests/TestView.swift b/CartographyTests/TestView.swift index 65a1a4d..5fc8d70 100644 --- a/CartographyTests/TestView.swift +++ b/CartographyTests/TestView.swift @@ -20,7 +20,7 @@ class TestView: View { } #if os(OSX) - override var flipped: Bool { + override var isFlipped: Bool { return true } diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..28e6a46 --- /dev/null +++ b/Podfile @@ -0,0 +1,10 @@ +use_frameworks! + +abstract_target "TestPods" do + pod 'Nimble', :git => 'https://github.com/Quick/Nimble.git' + pod 'Quick', :git => 'https://github.com/Quick/Quick.git' + + target 'Cartography-iOS-Tests' + target 'Cartography-Mac-Tests' + target 'Cartography-tvOS-tests' +end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 0000000..a472ba8 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,29 @@ +PODS: + - Nimble (5.0.0) + - Quick (0.9.3) + +DEPENDENCIES: + - Nimble (from `https://github.com/Quick/Nimble.git`) + - Quick (from `https://github.com/Quick/Quick.git`) + +EXTERNAL SOURCES: + Nimble: + :git: https://github.com/Quick/Nimble.git + Quick: + :git: https://github.com/Quick/Quick.git + +CHECKOUT OPTIONS: + Nimble: + :commit: 0209419661b6acceff45cd63984596f2e9eea517 + :git: https://github.com/Quick/Nimble.git + Quick: + :commit: ddd6036187e3cb0bc53bea1e8e7951b61a55304d + :git: https://github.com/Quick/Quick.git + +SPEC CHECKSUMS: + Nimble: 56fc9f5020effa2206de22c3dd910f4fb011b92f + Quick: 31fb576b6cbb6b028cc5e0016e4366accbb346f5 + +PODFILE CHECKSUM: 5c3f231fd128c753b666a5552cc91ff9c3581a61 + +COCOAPODS: 1.1.0.rc.2