A collection of operators and utilities that simplify iOS layout code.

Related tags

Layout Anchorage
Overview

Anchorage

Swift 4.2 + 5.0 CircleCI Version Platform Carthage compatible

A lightweight collection of intuitive operators and utilities that simplify Auto Layout code. Anchorage is built directly on top of the NSLayoutAnchor API.

Each expression acts on one or more NSLayoutAnchors, and returns active NSLayoutConstraints. If you want inactive constraints, here's how to do that.

Usage

Alignment

// Pin the button to 12 pt from the leading edge of its container
button.leadingAnchor == container.leadingAnchor + 12

// Pin the button to at least 12 pt from the trailing edge of its container
button.trailingAnchor <= container.trailingAnchor - 12

// Center one or both axes of a view
button.centerXAnchor == container.centerXAnchor
button.centerAnchors == container.centerAnchors

Relative Alignment

// Position a view to be centered at 2/3 of its container's width
view.centerXAnchor == 2 * container.trailingAnchor / 3

// Pin the top of a view at 25% of container's height
view.topAnchor == container.bottomAnchor / 4

Sizing

// Constrain a view's width to be at most 100 pt
view.widthAnchor <= 100

// Constraint a view to a fixed size
imageView.sizeAnchors == CGSize(width: 100, height: 200)

// Constrain two views to be the same size
imageView.sizeAnchors == view.sizeAnchors

// Constrain view to 4:3 aspect ratio
view.widthAnchor == 4 * view.heightAnchor / 3

Composite Anchors

Constrain multiple edges at a time with this syntax:

// Constrain the leading, trailing, top and bottom edges to be equal
imageView.edgeAnchors == container.edgeAnchors

// Inset the edges of a view from another view
let insets = UIEdgeInsets(top: 5, left: 10, bottom: 15, right: 20)
imageView.edgeAnchors == container.edgeAnchors + insets

// Inset the leading and trailing anchors by 10
imageView.horizontalAnchors >= container.horizontalAnchors + 10

// Inset the top and bottom anchors by 10
imageView.verticalAnchors >= container.verticalAnchors + 10

Use leading and trailing

Using leftAnchor and rightAnchor is rarely the right choice. To encourage this, horizontalAnchors and edgeAnchors use the leadingAnchor and trailingAnchor layout anchors.

Inset instead of Shift

When constraining leading/trailing or top/bottom, it is far more common to work in terms of an inset from the edges instead of shifting both edges in the same direction. When building the expression, Anchorage will flip the relationship and invert the constant in the constraint on the far side of the axis. This makes the expressions much more natural to work with.

Priority

The ~ is used to specify priority of the constraint resulting from any Anchorage expression:

// Align view 20 points from the center of its superview, with system-defined low priority
view.centerXAnchor == view.superview.centerXAnchor + 20 ~ .low

// Align view 20 points from the center of its superview, with (required - 1) priority
view.centerXAnchor == view.superview.centerXAnchor + 20 ~ .required - 1

// Align view 20 points from the center of its superview, with custom priority
view.centerXAnchor == view.superview.centerXAnchor + 20 ~ 752

The layout priority is an enum with the following values:

  • .required - UILayoutPriorityRequired (default)
  • .high - UILayoutPriorityDefaultHigh
  • .low - UILayoutPriorityDefaultLow
  • .fittingSize - UILayoutPriorityFittingSizeLevel

Storing Constraints

To store constraints created by Anchorage, simply assign the expression to a variable:

// A single (active) NSLayoutConstraint
let topConstraint = (imageView.topAnchor == container.topAnchor)

// EdgeConstraints represents a collection of constraints
// You can retrieve the NSLayoutConstraints individually,
// or get an [NSLayoutConstraint] via .all, .horizontal, or .vertical
let edgeConstraints = (button.edgeAnchors == container.edgeAnchors).all

Batching Constraints

By default, Anchorage returns active layout constraints. If you'd rather return inactive constraints for use with the NSLayoutConstraint.activate(_:) method for performance reasons, you can do it like this:

let constraints = Anchorage.batch(active: false) {
    view1.widthAnchor == view2.widthAnchor
    view1.heightAnchor == view2.heightAnchor / 2 ~ .low
    // ... as many constraints as you want
}

// Later:
NSLayoutConstraint.activate(constraints)

You can also pass active: true if you want the constraints in the array to be automatically activated in a batch.

Autoresizing Mask

Anchorage sets the translatesAutoresizingMaskIntoConstraints property to false on the left hand side of the expression, so you should never need to set this property manually. This is important to be aware of in case the container view relies on translatesAutoresizingMaskIntoConstraints being set to true. We tend to keep child views on the left hand side of the expression to avoid this problem, especially when constraining to a system-supplied view.

A Note on Compile Times

Anchorage overloads a few Swift operators, which can lead to increased compile times. You can reduce this overhead by surrounding these operators with /, like so:

Operator Faster Alternative
== /==/
<= /<=/
>= />=/

For example, view1.edgeAnchors == view2.edgeAnchors would become view1.edgeAnchors /==/ view2.edgeAnchors.

Installation

CocoaPods

To integrate Anchorage into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Anchorage'

Carthage

To integrate Anchorage into your Xcode project using Carthage, specify it in your Cartfile:

github "Rightpoint/Anchorage"

Run carthage update to build the framework and drag the built Anchorage.framework into your Xcode project.

License

This code and tool is under the MIT License. See LICENSE file in this repository.

Any ideas and contributions welcome!

Comments
  • Add custom operators as alternatives to overloaded operators

    Add custom operators as alternatives to overloaded operators

    This PR aims to solve the issue of slow type-checking performance due to operator overloading (see #83).

    To solve this, I've added new custom operators that provide the same functionality as the overloaded operators. Essentially, users can opt in by surrounding the overloaded operators in a "box of shame" (thanks, Zev):

    | Operator | New Alternative | |------|----------| | == | ~\|==\|~ (changed to /==/) | | <= | ~\|<=\|~ (changed to /<=/) | | >= | ~\|>=\|~ (changed to />=/) |

    This has a few benefits:

    • By using a custom operator rather than overloading existing operators, we reduce the amount of overhead accrued.
    • The existing operator overloads now fall back on the new operator alternatives, which prevents duplicated code and makes this PR non-breaking.

    Here's a build timing summary for an app that makes heavy use of Anchorage:

    Build Timing Summary
    
    CompileC (799 tasks) | 1121.137 seconds
    CompileSwiftSources (49 tasks) | 723.882 seconds
    CompileAssetCatalog (7 tasks) | 329.057 seconds
    CompileXIB (3 tasks) | 263.134 seconds
    Ld (74 tasks) | 89.242 seconds
    CompileStoryboard (4 tasks) | 59.476 seconds
    CopyPNGFile (60 tasks) | 51.361 seconds
    PhaseScriptExecution (4 tasks) | 10.858 seconds
    ValidateEmbeddedBinary (5 tasks) | 8.584 seconds
    IntentDefinitionCompile (3 tasks) | 6.932 seconds
    Ditto (367 tasks) | 6.898 seconds
    CodeSign (6 tasks) | 6.889 seconds
    IntentDefinitionCodegen (3 tasks) | 6.850 seconds
    CreateUniversalBinary (35 tasks) | 4.496 seconds
    Touch (36 tasks) | 4.284 seconds
    LinkStoryboards (3 tasks) | 0.042 seconds
    Libtool (2 tasks) | 0.021 seconds
    

    Here's the build timing summary after switching to this branch using my new operators:

    Build Timing Summary
    
    CompileC (799 tasks) | 1005.547 seconds
    CompileSwiftSources (49 tasks) | 682.290 seconds
    Ld (74 tasks) | 128.364 seconds
    CompileAssetCatalog (7 tasks) | 16.995 seconds
    CompileXIB (3 tasks) | 13.545 seconds
    ValidateEmbeddedBinary (5 tasks) | 12.560 seconds
    CopyPNGFile (60 tasks) | 10.077 seconds
    Ditto (367 tasks) | 8.374 seconds
    PhaseScriptExecution (4 tasks) | 7.390 seconds
    CompileStoryboard (4 tasks) | 7.034 seconds
    CreateUniversalBinary (35 tasks) | 5.416 seconds
    IntentDefinitionCompile (3 tasks) | 4.970 seconds
    IntentDefinitionCodegen (3 tasks) | 4.910 seconds
    CodeSign (6 tasks) | 2.332 seconds
    Touch (36 tasks) | 0.860 seconds
    LinkStoryboards (3 tasks) | 0.024 seconds
    Libtool (2 tasks) | 0.021 seconds
    

    Overall, the build time went from 4:55 to 3:22.

    enhancement 
    opened by colejd 13
  • Add support for multiplier constraints derived from axis anchors

    Add support for multiplier constraints derived from axis anchors

    The NSLayoutConstraint API allows for creation of constraints with both offset and multiplier not only between dimensions (width & height), but also between axial attributes (left, right, leading, trailing, center). Such constraints are useful for relative positioning of a subview within a parent view (e.g. position subview so that it's center point is located in the middle of its parent view on horizontal axis and at 25% of the parent view's height on the vertical axis).

    For some reason, Apple chose not to support creation of such constraints through the base NSLayoutAnchor API, and multiplier constraints are only exposed through the NSLayoutDimension subclass. Since Anchorage is wrapping the NSLayoutAnchor API, it also cannot be used to create these axial multiplier constraints.

    This PR introduces methods for creating multiplier constraints between axis anchors in extensions on NSLayoutXAxisAnchor and NSLayoutYAxisAnchor, as well as corresponding new functions to the Anchorage API.

    opened by sanekgusev 11
  • Use of `BinaryFloatingPoint` types with custom operators.

    Use of `BinaryFloatingPoint` types with custom operators.

    I feel like I'm probably just missing something stupid, but the following code demonstrates a problem I'm having:

    let n: Double = 44
    button.heightAnchor == 44 // works
    button.heightAnchor == CGFloat(n) // works
    button.heightAnchor == n // Failes with "Binary operator '==' cannot be applied to operands of type 'NSLayoutDimension' and 'Double'"
    

    I feel like it should work without wrapping it because of this operator definition: https://github.com/Raizlabs/Anchorage/blob/master/Source/Anchorage.swift#L45.

    Am I doing something wrong?

    opened by nickmshelley 7
  • Question: If I remove the constraint and change the property, do I need to add again?

    Question: If I remove the constraint and change the property, do I need to add again?

    Hey guys, I have one question. Having this code:

    viewTopAnchor = (view_1.topAnchor = view_2.topAnchor)
    

    then at some point I need to updated the viewTopAnchor property

    removeConstraint(viewTopAnchor)
    viewTopAnchor = (view_1.topAnchor = view_3.bottomAnchor)
    addConstraint(viewTopAnchor) // is this optional or mandatory after removeConstraint?
    

    The question is, due to the Anchorage is adding automatically the constraint when you declare it, should I add it manually if I remove and redeclare it again? Because seems that is I don't add it manually the view is broken.

    opened by carmelogallo 7
  • Feature/methods over operators

    Feature/methods over operators

    Hi, This is just refactor proposal for ongoing issue with slow infering .

    I've also created regular expression to replace most of operator usage with method. It still have to be perfected but basic idea works really nice :)

    I'd be perfect if we could use those regular expression in SwiftLint autocorrect

    Screenshot 2020-03-03 at 10 46 30

    // search: [a-w].Anchor == (.)Anchor.* // replace: constraint($1, $2)

    opened by Przemyslaw-Wosko 6
  • Provide functions to replace == overloads (WIP)

    Provide functions to replace == overloads (WIP)

    Resolving == types seems to really slow down build times on large projects. One idea is to provide an alternate set of anchorage functions that can replace ==, <=, >=, etc. So instead of viewA.topAnchor == viewB.topAnchor you would say viewA.topAnchor.pin(viewB.topAnchor) or something like that. I think there is still added value from Anchorage implementation, but maybe we should also consider a lighter-weight constraint helper to use with the newer/better Apple APIs (just adding edgeAnchors type conveniences, for example).

    AnchorageFast.swift extends all the anchoragable classes. Not able to see a build time difference in the demo app, but it is a pretty small code base. Not sure about the match() naming. Also considered pin() or set() or some other variant of equals(). Would love to come up with an ideal set of names that are more clear in function, but relatively brief.

    Still need to:

    • [ ] Support other operators (~ or +, etc.)
    • [ ] Replicate tests for new function
    • [ ] Old functions should call new functions for single implementations
    • [ ] Formally test build performance change
    • [ ] Finalize function naming scheme
    opened by minimusic 6
  • Support nested batches (without combining their constraints)

    Support nested batches (without combining their constraints)

    I have a feeling that you guys may have already considered this, but I thought I'd suggest this nested constraint batch implementation. IDK how this fits in conceptually, so treat this as a proposal.

    Right now Anchorage does not support nested batches at all and trying to create one while another batch is already in place is considered programming error. However, after I started using Anchorage extensively, I've found that this gets in the way every now and then, with higher-level code suddenly having to care/know about whether lower-level code is using batches to set up its constraints or not. At the same time, a naïve nested batch implementation is trivial to implement. Which is what this PR is about.

    Instead of keeping a global reference to a single (optional) active batch, I've expanded the concept to store a stack of active batches in an array, with newly created constraints being recorded into the most recent batch in the global “stack”. Now, this implementation keeps all the nested batches completely isolated from each other (i. e. constraints added to any of the nested batches would not appear and would not be affected by the active flag of the batches higher up in the batch stack). It feels reasonably intuitive to me, but I guess others might feel different.

    Thoughts?

    opened by sanekgusev 6
  • Prevent duplicate constraints.

    Prevent duplicate constraints.

    Adding constraints should probably prevent duplicates.

    From basic testing, duplicate constraints do not appear to cause technical problems. However, if those constraints are iterated/manipulated it could cause problems.

    ConstraintBatch would need to perform a "union" instead of "append". (See here.) Unfortunately, even though NSLayoutConstraint is Hashable, apparently duplicate constraints still have unique hash values, so Set can't be used to remove duplicates. You would need to do an Equatable based "union" instead. I have some code for that here.

    opened by davidbjames 5
  • Compile Time Mismatch Errors & centerAnchors

    Compile Time Mismatch Errors & centerAnchors

    Fixes #8 and #13:

    • Creates AnchorPair struct that creates constraints along 2 edges (or both centers)
    • Removes need for LayoutEdge enum (downside to this: "transforming" constraints is handled case-by-case)
    • EdgeAnchors composes from horizontalAnchors and verticalAnchors
    • ConstraintBuilder and EdgeConstraints (renamed to ConstraintGroup) add support for center anchors
    opened by nevillco 5
  • SwiftPM support

    SwiftPM support

    opened by TofPlay 5
  • Update for Swift 5.0

    Update for Swift 5.0

    On top of fixing up the podspec to include swift_version (#68) and fixing Xcode 10.2+ warnings (#73), this project should be updated to Swift 5.0.

    I took a quick pass at this and it appears to only require a few minor changes. However, someone with access needs to fix the CI build (it currently points to an inaccessible CircleCI page).

    opened by terenceyan 4
  • Bump addressable from 2.7.0 to 2.8.1

    Bump addressable from 2.7.0 to 2.8.1

    Bumps addressable from 2.7.0 to 2.8.1.

    Changelog

    Sourced from addressable's changelog.

    Addressable 2.8.1

    • refactor Addressable::URI.normalize_path to address linter offenses (#430)
    • remove redundant colon in Addressable::URI::CharacterClasses::AUTHORITY regex (#438)
    • update gemspec to reflect supported Ruby versions (#466, #464, #463)
    • compatibility w/ public_suffix 5.x (#466, #465, #460)
    • fixes "invalid byte sequence in UTF-8" exception when unencoding URLs containing non UTF-8 characters (#459)
    • Ractor compatibility (#449)
    • use the whole string instead of a single line for template match (#431)
    • force UTF-8 encoding only if needed (#341)

    #460: sporkmonger/addressable#460 #463: sporkmonger/addressable#463 #464: sporkmonger/addressable#464 #465: sporkmonger/addressable#465 #466: sporkmonger/addressable#466

    Addressable 2.8.0

    • fixes ReDoS vulnerability in Addressable::Template#match
    • no longer replaces + with spaces in queries for non-http(s) schemes
    • fixed encoding ipv6 literals
    • the :compacted flag for normalized_query now dedupes parameters
    • fix broken escape_component alias
    • dropping support for Ruby 2.0 and 2.1
    • adding Ruby 3.0 compatibility for development tasks
    • drop support for rack-mount and remove Addressable::Template#generate
    • performance improvements
    • switch CI/CD to GitHub Actions
    Commits
    • 8657465 Update version, gemspec, and CHANGELOG for 2.8.1 (#474)
    • 4fc5bb6 CI: remove Ubuntu 18.04 job (#473)
    • 860fede Force UTF-8 encoding only if needed (#341)
    • 99810af Merge pull request #431 from ojab/ct-_do_not_parse_multiline_strings
    • 7ce0f48 Merge branch 'main' into ct-_do_not_parse_multiline_strings
    • 7ecf751 Merge pull request #449 from okeeblow/freeze_concatenated_strings
    • 41f12dd Merge branch 'main' into freeze_concatenated_strings
    • 068f673 Merge pull request #459 from jarthod/iso-encoding-problem
    • b4c9882 Merge branch 'main' into iso-encoding-problem
    • 08d27e8 Merge pull request #471 from sporkmonger/sporkmonger-enable-codeql
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump tzinfo from 1.2.7 to 1.2.10

    Bump tzinfo from 1.2.7 to 1.2.10

    Bumps tzinfo from 1.2.7 to 1.2.10.

    Release notes

    Sourced from tzinfo's releases.

    v1.2.10

    TZInfo v1.2.10 on RubyGems.org

    v1.2.9

    • Fixed an incorrect InvalidTimezoneIdentifier exception raised when loading a zoneinfo file that includes rules specifying an additional transition to the final defined offset (for example, Africa/Casablanca in version 2018e of the Time Zone Database). #123.

    TZInfo v1.2.9 on RubyGems.org

    v1.2.8

    • Added support for handling "slim" format zoneinfo files that are produced by default by zic version 2020b and later. The POSIX-style TZ string is now used calculate DST transition times after the final defined transition in the file. The 64-bit section is now always used regardless of whether Time has support for 64-bit times. #120.
    • Rubinius is no longer supported.

    TZInfo v1.2.8 on RubyGems.org

    Changelog

    Sourced from tzinfo's changelog.

    Version 1.2.10 - 19-Jul-2022

    Version 1.2.9 - 16-Dec-2020

    • Fixed an incorrect InvalidTimezoneIdentifier exception raised when loading a zoneinfo file that includes rules specifying an additional transition to the final defined offset (for example, Africa/Casablanca in version 2018e of the Time Zone Database). #123.

    Version 1.2.8 - 8-Nov-2020

    • Added support for handling "slim" format zoneinfo files that are produced by default by zic version 2020b and later. The POSIX-style TZ string is now used calculate DST transition times after the final defined transition in the file. The 64-bit section is now always used regardless of whether Time has support for 64-bit times. #120.
    • Rubinius is no longer supported.
    Commits
    • 0814dcd Fix the release date.
    • fd05e2a Preparing v1.2.10.
    • b98c32e Merge branch 'fix-directory-traversal-1.2' into 1.2
    • ac3ee68 Remove unnecessary escaping of + within regex character classes.
    • 9d49bf9 Fix relative path loading tests.
    • 394c381 Remove private_constant for consistency and compatibility.
    • 5e9f990 Exclude Arch Linux's SECURITY file from the time zone index.
    • 17fc9e1 Workaround for 'Permission denied - NUL' errors with JRuby on Windows.
    • 6bd7a51 Update copyright years.
    • 9905ca9 Fix directory traversal in Timezone.get when using Ruby data source
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump cocoapods-downloader from 1.4.0 to 1.6.3

    Bump cocoapods-downloader from 1.4.0 to 1.6.3

    Bumps cocoapods-downloader from 1.4.0 to 1.6.3.

    Release notes

    Sourced from cocoapods-downloader's releases.

    1.6.3

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.2

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.1

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.0

    Enhancements
    • None.
    Bug Fixes
    • Adds a check for command injections in the input for hg and git.
      orta #124

    1.5.1

    Enhancements
    • None.
    Bug Fixes
    • Fix "can't modify frozen string" errors when pods are integrated using the branch option
      buju77 #10920

    1.5.0

    ... (truncated)

    Changelog

    Sourced from cocoapods-downloader's changelog.

    1.6.3 (2022-04-01)

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.2 (2022-03-28)

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.1 (2022-03-23)

    Enhancements
    • None.
    Bug Fixes
    • None.

    1.6.0 (2022-03-22)

    Enhancements
    • None.
    Bug Fixes
    • Adds a check for command injections in the input for hg and git.
      orta #124

    1.5.1 (2021-09-07)

    Enhancements
    • None.

    ... (truncated)

    Commits
    • c03e2ed Release 1.6.3
    • f75bccc Disable Bazaar tests due to macOS 12.3 not including python2
    • 52a0d54 Merge pull request #128 from CocoaPods/validate_before_dl
    • d27c983 Ensure that the git pre-processor doesn't accidentally bail also
    • 3adfe1f [CHANGELOG] Add empty Master section
    • 591167a Release 1.6.2
    • d2564c3 Merge pull request #127 from CocoaPods/validate_before_dl
    • 99fec61 Switches where we check for invalid input, to move it inside the download fun...
    • 96679f2 [CHANGELOG] Add empty Master section
    • 3a7c54b Release 1.6.1
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Carthage problems on Xcode 12

    Carthage problems on Xcode 12

    I'm having a problem using Anchorage with XCode 12 and iOS 14. Running on a simulator I get - (if using command line tools 11.7 for Carthage) "Building for iOS Simulator, but the linked framework 'Anchorage.framework' was built for iOS."

    If I use command line tools 12 for Carthage build fails ("Task failed with exit code 1: ,, This usually indicates that project itself failed to compile."). I checked the xcode logs and they succeeded but with many warnings - "*.pcm: No such file or directory." If anyone one has any ideas or need more info to investigate that would be great.

    My biggest question though is if Anchorage is still supported and if this issue is on my side or should I wait for a fix? I was also thinking of pulling the Anchorage source, try fix myself and add the framework in the project, but I don't know if that's a good idea?

    Any help would be great.

    opened by brettambrosestuart 3
  • Add a logo

    Add a logo

    Found this in my old photos, circa 2017. Guessing Samantha Broccoli or one of the other Raizlabs designers drew it. Could be the nice basis for a logo. 8A016878-F9DE-42A1-8FDD-84C33139D10F

    opened by ZevEisenberg 0
  • Type-checking Performance

    Type-checking Performance

    We're using anchorage in our app and have something akin to this in our xcconfig:

    OTHER_SWIFT_FLAGS = -Xfrontend -warn-long-function-bodies=400 -Xfrontend -warn-long-expression-type-checking=400

    We compile Anchorage from source due to needing a static lib and Anchorage code as well as our app are consistently causing warnings.

    For Anchorage, it's the performInBatch(closure:) call in func constraints(forAnchors:, firstConstant c1:, secondConstant:, priority:, builder:) (Internal.swift).

    In our app, functions that have numerous calls to Anchorage.batch(active:closure:) ini the same function tends to also fail this check.

    opened by vlozko 10
Releases(4.5.0)
  • 4.5.0(Oct 30, 2020)

  • 4.4.0(Feb 3, 2020)

    New Features

    • Swift Package Manager support #86 (thanks @ZevEisenberg!)
    • Runs tests using Xcode 11 for Swift 4.2 and 5.0

    Deprecations

    • Drops official support for Xcode 10.x and Swift 4.0, although they should still continue to work.

    See all commits since 4.3.1.

    Source code(tar.gz)
    Source code(zip)
  • 4.3.1(May 31, 2019)

  • 4.3(Sep 22, 2018)

  • 4.2.4(Jun 25, 2018)

    See all commits since 4.2.3.

    Bug Fixes

    • Allow construction of an AnchorPair outside of Anchorage. (#59, @ZevEisenberg)
      • Note: this change is non-breaking, but to realize its benefits, you may need to delete code like this if you had added it to your project:

        extension AnchorPair {
            init(first: T, second: U) {
                self.first = first
                self.second = second
            }
        }
        
    Source code(tar.gz)
    Source code(zip)
  • 4.2.3(Jun 20, 2018)

  • 4.2.2(Apr 18, 2018)

  • 4.2.1(Dec 19, 2017)

  • 4.2.0(Nov 29, 2017)

  • 4.1.0(Sep 25, 2017)

    Anchorage 4.1 adds support for Xcode 9, iOS 11, tvOS 11, and macOS 10.13.

    This version also drops support for Float80. If you were previously using this floating-point type in UI code, you may want to... reconsider.

    Source code(tar.gz)
    Source code(zip)
  • 4.0.0(May 10, 2017)

    Anchorage 4 adds a new batching API for creating multiple constraints, with the ability to return inactive constraints if you need them. It also improves the API in many places, restructures the code to be more maintainable, and drops Swift 2.3 support. See the ReadMe for a full rundown of the current feature set.

    New Features

    • Batching: any constraints created in the batch will not be activated until the whole batch returns. Optionally, you can write batch(active: false) { ... } to get back inactive constraints with Auto Layout's batch-activation mechanism.
    • Added sizeAnchors: you can now pin a view's size to a literal CGSize or another view's size anchors in a single line of code.
    • Added support for using (UI/NS)EdgeInsets when constraining edge anchors; useful for margins when not using layoutMarginsGuide.

    Improvements

    • Expanded and improved the use of layout priority shorthand enum from #33. This is now the preferred way to adjust priority in Anchorage.
    • Added tests

    Breaking Changes

    • dropped Swift 2.3 support
    • minor changes that may make some priority-related code fail to compile. This code should be converted to the much more concise new shorthand syntax; see the ReadMe for details.
    • the following have been renamed:
      • AxisGroupConstraintPair
      • EdgeGroupConstraintGroup
      • LayoutPriorityPriority

    Bug fixes

    • Fixed copy/paste errors that resulted in incorrect constraints being created (https://github.com/Raizlabs/Anchorage/pull/37/commits/9891570de90226eb3bd2c09c48c30b4ffc0e19d9)
    Source code(tar.gz)
    Source code(zip)
  • 3.2.0(Mar 30, 2017)

  • 3.1.0(Feb 22, 2017)

    • Priority operator precedence adjusted so that parens aren't required for most expressions
    • Anchorage now supports OS X thanks to @mattprowse !
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Feb 17, 2017)

  • 2.0.1(Jul 18, 2016)

Owner
Rightpoint
Rightpoint is an independent customer experience agency with technology at our core.
Rightpoint
A Code challenge I solved leveraging a lot on Composite collection view layout written in swift

AsthmApp Mobile app designed as a support aid for people with Asthma Accounts Google and Firebase [email protected] dICerytiMPSI Facebook asthmp.ap

null 0 Dec 13, 2021
A Code challenge I solved leveraging a lot on Composite collection view layout...written in swift

Space44 Code Challenge Space44 Code Challenge iOS application for Space 44 hiring process, it leverages on Image download and composite collection vie

null 0 Dec 16, 2021
Auto Layout (and manual layout) in one line.

Auto Layout (and manual layout) in one line. Quick Look view.bb.centerX().below(view2).size(100) It’s equivalent to iOS 9 API: view.centerXAnchor.cons

Javier Zhang 74 Oct 19, 2022
Auto Layout made easy with the Custom Layout.

Auto Layout made easy with the Custom Layout. Getting started CocoaPods CocoaPods is a dependency manager for Cocoa projects. You can install it with

Malith Nadeeshan 1 Jan 16, 2022
AppStoreClone - Understanding the complex layout of app store using UICompositional layout in swift

AppStoreClone Understanding the complex layout of app store using UICompositiona

Dheeraj Kumar Sharma 8 Dec 28, 2022
A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewFlowLayout.

WrapLayout A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewF

Hiroshi Kimura 6 Sep 27, 2022
Flow layout / tag cloud / collection view in SwiftUI.

SwiftUIFlowLayout A Flow Layout is a container that orders its views sequentially, breaking into a new "line" according to the available width of the

Gordan Glavaš 115 Dec 28, 2022
A flexible collection view with proper horizontal layout flow

FlexCollection A very simple flexible collection view using SwiftUI that automat

null 1 Dec 29, 2021
Reframing SwiftUI Views. A collection of tools to help with layout.

Overview A Swift Package with a collection of SwiftUI framing views and tools to help with layout. Size readers like WidthReader, HeightReader, and on

Ryan Lintott 84 Dec 16, 2022
Modern-collection-view - Modern collection view for swift

Modern collection view Sample application demonstrating the use of collection vi

Nitanta Adhikari 1 Jan 24, 2022
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

layoutBox 2.1k Dec 22, 2022
Written in pure Swift, QuickLayout offers a simple and easy way to manage Auto Layout in code.

QuickLayout QuickLayout offers an additional way, to easily manage the Auto Layout using only code. You can harness the power of QuickLayout to align

Daniel Huri 243 Oct 28, 2022
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

layoutBox 2.1k Jan 2, 2023
UIView category which makes it easy to create layout constraints in code

FLKAutoLayout FLKAutoLayout is a collection of categories on UIView which makes it easy to setup layout constraints in code. FLKAutoLayout creates sim

Florian Kugler 1.5k Nov 24, 2022
Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout

Masonry Masonry is still actively maintained, we are committed to fixing bugs and merging good quality PRs from the wider community. However if you're

null 18k Jan 5, 2023
BrickKit is a delightful layout library for iOS and tvOS. It is written entirely in Swift!

BrickKit is a delightful layout library for iOS and tvOS. It is written entirely in Swift! Deprecated BrickKit is being phased out at Wayfair, and the

Wayfair Tech – Archive 608 Sep 15, 2022
LayoutKit is a fast view layout library for iOS, macOS, and tvOS.

?? UNMAINTAINED ?? This project is no longer used by LinkedIn and is currently unmaintained. LayoutKit is a fast view layout library for iOS, macOS, a

LinkedIn's Attic 3.2k Dec 27, 2022
An easy way to create and layout UI components for iOS (Swift version).

Introduction Cupcake is a framework that allow you to easily create and layout UI components for iOS 8.0+. It use chaining syntax and provides some fr

nerdycat 288 Oct 9, 2022
The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. Objective-C and Swift compatible.

The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. PureLayout extends UIView/NSView, NSArray, and NSLayoutConstrai

PureLayout 7.6k Jan 6, 2023