𝗟𝗲𝘁’𝘀 𝗦𝗵𝗮𝗿𝗲 𝗦𝗵𝗼𝗿𝘁𝗰𝘂𝘁 𝗧𝗲𝗰𝗵𝗻𝗶𝗾𝘂𝗲𝘀
built to share shortcut techniques with others creating shortcuts
The purpose of this shortcut is to share techniques that I and others have learned as we've developed workflows and shortcuts. I plan to update this shortcut periodically.
If you have any snippets that you would like to share, please leave a comment (at https://routinehub.co/shortcut/1189) and I'll add them to the next update of this shortcut.
WARNING: In the following Dictionary action, the 'MyName' item must match the name of this shortcut.
Let’s Share Shortcut Techniques [default]
[Do not change the contents of this comment.]
~~~ Start of Setup Parameters ~~~
~~~ End of Setup Parameters ~~~
Note that in the next several actions, a settings file is used. This file is located in the /iCloud Drive/shortcutName. With some shortcuts, it might also be appropriate to also have device-specific settings.
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Determine if a "new build" message should be displayed, based on the following...
(MyBuild This Shortcut) - (MyBuild Previous Run) > (Startup Alert.Build Delta)
Note: For the technique to work property, MyBuild must be an integer or decimal number. That is, it cannot be in the form of n.n.n (e.g., 1.0.2).
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Example Daily Alert
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Update the settings file.
Note: When updating a dictionary, each 'Set [Key] to [Value] in [Dictionary]' needs to refer to the Dictionary from the previous action*, not the Dictionary originally opened (or created).
* The easiest method to do this is via 'Dictionary' Magic variables.
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
Determine if a periodic check for update should be done based on the number of days that have elapsed since the last check.
0 = never check
n = days that must elapse before the check is made
𝗧𝗵𝗲 𝗳𝗼𝗹𝗹𝗼𝘄𝗶𝗻𝗴 𝗰𝗵𝗲𝗰𝗸 𝗳𝗼𝗿 𝘂𝗽𝗱𝗮𝘁𝗲 𝗮𝗰𝘁𝗶𝗼𝗻𝘀 𝗮𝗿𝗲 𝗮𝗱𝗮𝗽𝘁𝗲𝗱 𝗳𝗿𝗼𝗺:
[Eᴍʙᴇᴅ-ᴀ-Uᴘᴅᴀᴛᴇ], https://routinehub.co/shortcut/2672
There is no network connection, thus an update check could not be made.
Array
Set 'Check for Update' in the settings file to today's date. During subsequent runs of this shortcut, this saved setting and 'Check for Update.Elapsed Days' will be used to determine if a periodic automatic update check should be executed.
Array
🤔‼️🤔‼️🤔‼️🤔‼️🤔‼️🤔
This section is included due to odd behavior that is observerd on my iPad Pro 10.5 (only)...
🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴
🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴
🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴
EDITING NOTE: If you are interested in viewing the actions associated with one of the below techniques, here's a suggestion: rather than scrolling through potentially hundreds of actions, use the 'Choose from Menu' action below and move the 'technique of interest' to the top.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
SF Symbol for vCard Menu
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Create Help and Display in Safari (Markdown Source)
Replace smart quotes, smart single quotes, en dash, and em dash.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Shortcut Update Initiated by User
⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️🔴⚫️⚫️
The following set of actions complete an 'On Demand' check for a shortcut update.
𝗧𝗵𝗲 𝗳𝗼𝗹𝗹𝗼𝘄𝗶𝗻𝗴 𝗰𝗵𝗲𝗰𝗸 𝗳𝗼𝗿 𝘂𝗽𝗱𝗮𝘁𝗲 𝗮𝗰𝘁𝗶𝗼𝗻𝘀 𝗮𝗿𝗲 𝗮𝗱𝗮𝗽𝘁𝗲𝗱 𝗳𝗿𝗼𝗺:
[Eᴍʙᴇᴅ-ᴀ-Uᴘᴅᴀᴛᴇ], https://routinehub.co/shortcut/2672
Set 'Check for Update' in the settings file to today's date. During subsequent runs of this shortcut, this saved setting and 'Check for Update.Elapsed Days' could be used to determine if a periodic automatic update check should be executed.
With iOS 13.1.3, the If action below did not evaluate correctly when it read as follows:
If 'My Shortcuts' eq UpdateKit.
The problem was corrected by changing the If operator to 'contains' but contains is not available until touching on 'My Shortcuts' and changing 'as Shortcut' to 'as Text'.
Note that this approach is not 100% reliable any shortcut name that includes UpdateKit will be falsely identified as 'UpdateKit'.
Note: To support, x.x.x version formats (e.g., 1.0.1) 'Current Version' must be a 'Text' Key (not 'Number').
Note: When configuring the 'Run Shortcut' action, do not use Choose because if the shortcut is renamed or deleted, the next action can loose the Shortcut value.
UpdateKit was not found. Give the user the option to browse to the site which includes a download link.
If the user chooses to download UpdateKit, the 'floating OK button' appears if the 'Exit Shortcut' action is not included.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Pick Subset of Shortcuts - all | select | text
𝗹𝗲𝗮𝘃𝗲 𝗯𝗹𝗮𝗻𝗸 ~ 𝗍𝗈 𝗂𝗇𝖼𝗅𝗎𝖽𝖾 𝖺𝗅𝗅 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌
In iOS 13, there is no 'Get Variable' action. The following 'Filter' action effectively achieves that same objective.
𝗮 𝘀𝗽𝗮𝗰𝗲 ~ 𝗍𝗈 𝗌𝖾𝗅𝖾𝖼𝗍 𝖿𝗋𝗈𝗆 𝖺𝗅𝗅 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌
𝙩𝙚𝙭𝙩 ~ 𝗍𝗈 𝗌𝖾𝗅𝖾𝖼𝗍 𝖿𝗋𝗈𝗆 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌 𝗐𝗂𝗍𝗁 𝖺 𝗇𝖺𝗆𝖾 𝖼𝗈𝗇𝗍𝖺𝗂𝗇𝗂𝗇𝗀 𝙩𝙚𝙭𝙩.
One or more matches.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Pick Subset of Shortcuts - all pre | none pre | text
𝗹𝗲𝗮𝘃𝗲 𝗯𝗹𝗮𝗻𝗸 ~ 𝗍𝗈 𝗌𝖾𝗅𝖾𝖼𝗍 𝖿𝗋𝗈𝗆 𝖺𝗅𝗅 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌, 𝗮𝗹𝗹 𝗉𝗋𝖾𝗌𝖾𝗅𝖾𝖼𝗍𝖾𝖽
𝗮 𝘀𝗽𝗮𝗰𝗲 ~ 𝗍𝗈 𝗌𝖾𝗅𝖾𝖼𝗍 𝖿𝗋𝗈𝗆 𝖺𝗅𝗅 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌, 𝗻𝗼𝗻𝗲 𝗉𝗋𝖾𝗌𝖾𝗅𝖾𝖼𝗍𝖾𝖽
𝙩𝙚𝙭𝙩 ~ 𝗍𝗈 𝗌𝖾𝗅𝖾𝖼𝗍 𝖿𝗋𝗈𝗆 𝗌𝗁𝗈𝗋𝗍𝖼𝗎𝗍𝗌 𝗐𝗂𝗍𝗁 𝖺 𝗇𝖺𝗆𝖾 𝖼𝗈𝗇𝗍𝖺𝗂𝗇𝗂𝗇𝗀 𝙩𝙚𝙭𝙩.
One or more matches.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Backup, Archive, and Restore Shortcuts
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Create vCard Menu with SF Symbol Photos
The Dictionary action below includes the icons for the vCard (a.k.a. Contact) menu. Specifically it contains 'Text' values that are encoded photos. There are a variety of methods that can be used to encode a JPEG or PNG including the 'Base64 Encode' shortcut action. For this example menu, the following shortcut was used to create the 3 example encoded photos of Apple's SF Symbols:
[SF Symbol for vCard Menu](https://www.icloud.com/shortcuts/64cd0a3789f846b7a01ab87a928e4a9c)
'Renamed Item' in the next action, 'Choose from List,' is a Magic Variable for the 'Set Name' action above.
Note: 'Renamed Item' below must be changed from 'as Text' to 'as Contact'.
This section shows three methods to get a Text Value (ABC) for a Key (K1 [in D2 [in D1]]) within a Dictionary (D2 [in D1]) that is within another Dictionary (D1).
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Search For a Shortcut
Technique worked with iOS 12, but does not with iOS 13.
Note: 'My Shortcuts' needs to be changed from 'as Shortcut' to 'as Text'.
Technique will generate false positives because it match 'UpdateKit' but will also match any shortcut that contain 'UpdateKit' in the name.
Note: 'My Shortcuts' needs to be changed from 'as Shortcut' to 'as Text'.
Technique works correctly with iOS 13 (and earlier).
Note: 'Repeat Item 2' needs to be changed from 'as Shortcut' to 'as Text'.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Force Execution in the Shortcuts App
Many shortcuts do not run well in the Shortcuts Widget because they require more memory than is allocated to shortcuts running in the widget. 'Continue Shortcut in App' switches to the Shortcuts app and continues to the next action.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
FileExist? TRUE, return contents; FALSE, create file, set contents
Credit to @canibeanartist and @heyitzspencer.
Actions below check for a file.
If it exists, it returns the contents of the file.
If it does not, it is created and set to 'New File Contents'; it returns 'New File Contents'.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Dictionary & RepeatWithEach to ReplaceText x N
Actions below illustrate the use of a Dictionary within a Dictionary and a technique that could be used to complete many 'Replace Text' actions. For this example, text replacements will be done for curly double quotes, single question, em dash, and en dash to web browser compatible codes.
From a practical standpoint, one advantage of using a Dictionary within a Dictionary is that the Dictionary action in the Shortcut editor is more compact.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Write to a Device-specific iCloud Folder
The backup path will include this Shortcut Name and the Device Name. The latter ensures that each iOS device will back up to a unique folder.
Note: Characters in the Device Name that are illegal iOS path characters are removed.
Remove any problematic characters that could appear in the Device Name.
If it does not already exist, create a device-specific folder.
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Generate a Multiple Line Prompt (e.g., With Ask for Input)
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
IF with OR logic
Method 1
Method 2
Method 3
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
🔴🔴▫️🔴🔴 ▫️▫️🔴▫️▫️
🔴▫️🔴▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️▫️🔴▫️▫️
🔴▫️▫️▫️🔴 ▫️🔴🔴🔴▫️
Write Contents of Dictionary to a New Note
Suppose your shortcut contains a dictionary that the user configures. The following actions could be included before running UpdateKit.
Open the Dictionary contents (JSON converted to text) in Notes.