Some Swift code that might be useful - an autosizing text field that is configurable within Interface Builder. When its multiline property is set to true, it wraps vertically as you type. It will otherwise expand and contract horizontally, obeying other constraints you've placed on it including minimum or maximum width.
MIT licensed - please feel free to use this however you'd like.