Skip to content

Migrating from PureLayout v2.x to v3.0

Tyler Fox edited this page Aug 17, 2015 · 19 revisions

PureLayout v3.0.0

PureLayout v3.0.0 is a major release, with new APIs, enhancements, and other changes. See the release notes for an overview of changes.

Moved APIs

The most significant breaking change in PureLayout v3.0.0 is the move of the following class methods from their original location on UIView/NSView to their new location on NSLayoutConstraint:

  • +[autoCreateConstraintsWithoutInstalling:]
  • +[autoSetPriority:forConstraints:]
  • +[autoSetIdentifier:forConstraints:]

When migrating existing code using v2.x to v3.0.0, you just need to change the class name at each call site. For example, this code using PureLayout v2.x:

[UIView autoSetPriority:UILayoutPriorityDefaultHigh forConstraints:^{ /* ... */ }];

Simply changes to the following with PureLayout v3.0.0:

[NSLayoutConstraint autoSetPriority:UILayoutPriorityDefaultHigh forConstraints:^{ /* ... */ }];

Easily Convert using Find & Replace

You can use a global find & replace in Xcode with the following regular expression patterns to quickly & automatically convert older v2.x API calls to their new v3.0 versions.

Objective-C

Find Regex Pattern:

(\[\s*)(UIView|NSView|ALView)(\s+(autoCreateConstraintsWithoutInstalling|autoSetPriority|autoSetIdentifier):)

Replace Regex Pattern:

$1NSLayoutConstraint$3

Swift

Find Regex Pattern:

(UIView|NSView|ALView)(\w*\.\w*(autoCreateConstraintsWithoutInstalling|autoSetPriority|autoSetIdentifier)\w*\()

Replace Regex Pattern:

NSLayoutConstraint$2

Removed APIs

The APIs that were deprecated in PureLayout v2.0.0 have been removed entirely. You weren't using those anymore, right? 😉 See this section of the v1.x to v2.0 Migration Guide for more details.

Other changes

None of the other changes in PureLayout v3.0.0 should require any immediate changes to existing code using v2.x. However, take a look through the release notes to learn about the new APIs that you can adopt.

Clone this wiki locally