The Extract Variable refactoring wraps a selected expression into a variable. It adds a new variable declaration and uses the expression as an initializer. To invoke this refactoring, select the expression and press &shortcut:IntroduceVariable; (Refactor | Extract/Introduce | Variable).

Extracted variable

For Swift, you can select whether you want to declare a variable (var) or a constant (let) using the Declare with var checkbox in the popup that appears. Also, you can uncheck the Specify type explicitly option if you don't want to add a type annotation to the variable declaration.