Created
May 21, 2018 04:24
-
-
Save dongyuwei/e82cbd0f5f8ed65842bd421a2a6ac023 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const exec = require("child_process").execSync; | |
const devicePreferences = exec( | |
`/usr/libexec/PlistBuddy -c "Print :DevicePreferences" ~/Library/Preferences/com.apple.iphonesimulator.plist` | |
).toString(); | |
const regexp = /\s+([A-Za-z0-9-]+)\s=\sDict\s\{/g; | |
let matched = []; | |
while ((matched = regexp.exec(devicePreferences)) !== null) { | |
const simulatorUuid = matched[1]; | |
try { | |
exec( | |
`/usr/libexec/PlistBuddy -c "Set :DevicePreferences:${simulatorUuid}:ConnectHardwareKeyboard false" ~/Library/Preferences/com.apple.iphonesimulator.plist` | |
); | |
} catch (error) { | |
exec( | |
`/usr/libexec/PlistBuddy -c "Add :DevicePreferences:${simulatorUuid}:ConnectHardwareKeyboard bool false" ~/Library/Preferences/com.apple.iphonesimulator.plist` | |
); | |
} | |
} |
Author
dongyuwei
commented
May 21, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment