How to Pass Variables in iOS 12 Shortcuts
Passing variables between actions in iOS 12 Shortcuts allows you to build dynamic, multi-step automations by transferring data from one task to another. In iOS 12, data flows sequentially by default, but you can also pass specific data across non-consequential steps using Magic Variables or manually defined Named Variables. This guide outlines how to utilize both methods effectively to connect your shortcut actions.
1. Automatic Sequential Flow
By default, Shortcuts passes the output of one action directly into the input of the next action immediately below it. If Action A creates an output (such as text or a photo) and Action B accepts that data type, a thin vertical line connects them in the editor, indicating that the data transfers automatically without requiring any extra setup.
2. Using Magic Variables
Magic Variables allow you to reference the output of any previous action without needing to save it manually. This is the preferred method in iOS 12 for referencing data several steps later.
- Add the action where you want to use data from an earlier step.
- Tap inside the text field or parameter where the variable should go.
- Above the keyboard, tap the Magic Variable button (represented by a wand icon) or select Select Magic Variable.
- Scroll up through your shortcut and tap the highlighted output of the action you wish to pass into the current field.
- The variable appears as a blue token inside your action parameter. You can tap this token to adjust its type (e.g., as text, file, URL, or date).
3. Using Explicit Named Variables
If you need to reuse the same piece of data multiple times, modify it inside a loop, or organize complex workflows, you can assign it a custom name.
- Add the Set Variable action directly beneath the action producing the data.
- Enter a name for your variable (e.g.,
UserNameorCurrentLocation). - Later in your shortcut, retrieve this data by adding the Get Variable action and selecting your named variable.
- Alternatively, you can insert the named variable directly into compatible text fields by selecting it from the variable bar located above the keyboard.
4. Appending Multiple Items to a Variable
To combine multiple outputs into a list, use the Add to Variable action. Each time this action runs, it appends the current input to the designated variable without overwriting the previous values, allowing subsequent actions to process the entire collection at once.