Skip to content

Instantly share code, notes, and snippets.

@Angles
Last active July 21, 2021 08:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Angles/d387d940a41b085d7efb to your computer and use it in GitHub Desktop.
Save Angles/d387d940a41b085d7efb to your computer and use it in GitHub Desktop.
iOS so-call (text) keyboard shorts which is text expansion can be a pain

iCloud Documents and Data Sharing

NOTE: this is from pre-iCloud Drive era, I do not know if still applies

FYI unrelated info, iOS 8 has "lexicon pairs for custom keyboards" for example, this dev doc,
requestSupplementaryLexiconWithCompletion

Back to original gist, Doc and Data sharing and keyboard expansion

iCloud What is one thing you can not turn off?

Summary: iOS/OSX text expansion snippets - On iOS called "Keyboard Shortcuts", on OSX called "Text Replacement".*

Summary: TERMINAL ACCESS. (more below)

defaults read -g NSUserDictionaryReplacementItems
defaults read -g NSUserReplacementItems
# details below
sqlite3 CloudUserDictionary.sqlite
sqlite> select * from ZUSERDICTIONARYENTRY;
# (you get dome approximation of your shortcuts)
sqlite> .exit

Shared: "keyboard shortcuts" on IOS, where is CMD key? They are stored on the device in a database called UserDictionary.sqlite and/or another called CloudUserDictionary.sqlite? But it is not for my custom spellings? And on OSX the preference key name combines UserDictionary with ReplacementItem? Yet they call it "keyboard shortcuts" too? They mean text expansion, but use names very similar to other things:

  1. "Shortcuts" are usually like CMD-C or CTRL-[, keyboard keystoke shortcuts.
  2. User Dictionary, that's usually your personal exceptions for spell checking.
  3. but here I am refering to the text expansion "kayboard shortcuts", got it?!?

How your computer and device "shortcuts" are shared.

On Mavericks you get iCloud on you computer, and can share things like the Notes seamlessly with the iOS iCloud. To do this, you turn on Document and Data Sharing in Maverick's iCloud preferences. Then there is a sub-menu where you can turn this off and on for specific apps. ok it's kinda neat. BUT IN THAT SUBMENU, YOU WILL NOT FIND AN ON/OFF SWITCH FOR SHARING "KEYBOARD SHORTCUTS".

KNOW THIS YOUNG GRASSHOPPER: with Doc and Data sharing,

Keyboard Expansion, so-called text shortcuts, sharing has NO on/off switch

You may never have a problem with this. If so, good for you. Otherwise, it made a serious pain in the a22 for me. It's rare.

How to inspect with terminal commands

Defaults read and sqlite3. How, where, when: Your device backups will put these sqlite database files on your computer for inspection using sqlite3. You can not access them on the device itself, (i am to lazy to jailbreak). Also,
If you have Mavericks Doc and Data sharing on, (a) all the database files will be on your computer, per device, and also, (b) in this case, your OSX data will be there in cloud form, as well as in your own OSX preferences.

sqlite3 CloudUserDictionary.sqlite
sqlite> select * from ZUSERDICTIONARYENTRY;
# (you get dome approximation of your shortcuts)
sqlite> .exit

Well now, CloudUserDictionary.sqlite that's the iCloud-era database. Sometimes the older incarnation of that file is still around, UserDictionary.sqlite it's from before you had iCloud, and it was supposed to be updated and replaced, but sometimes it is still there. (Way way back, these were stored in a plist file on the device, but that was a long time ago).

On Mavericks we can peek at these "shortcuts" you're maybe sharing, with the defaults command. I am pretty sure the NSUserDictionaryReplacementItems is iCloud shared, but IF Maveriks Doc and Data Sharing is off, that is, without iCloud sharing, the NSUserReplacementItems preference is used. But you likely have both.

# if your Mavericks has Doc and Data sharing turned on:
defaults read -g NSUserDictionaryReplacementItems
# this is what OSX used exclusively before iCloud
defaults read -g NSUserReplacementItems

There's more, but that get's you started if you are having problems with it which is kinda rare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment