Preview a view of SwiftUI from AppCode
1 min readApr 4, 2020
We can see a preview of the SwiftUI view on Xcode. But I want to use AppCode. So I make a way to preview the view on Xcode from AppCode.
First, I made AppCode open a file of view with Xcode in the following way.
- Open preferences of AppCode.
- Tools -> External Tools
- Create an external tool.
- Input… Name: Xcode, Program: open Arguments: -a Xcode $FilePath$, WorkingDirectory: $ProjectFileDir$
- Open Keymap pref view.
- Assign shortcut key [Control+Shift+X] to the ‘Xcode’ item.
Second, I made the following script in AppleScript. AppCode application name needs to be changed according to the version.
tell application "AppCode 2020.1 EAP" to activatedelay 0.1tell application "System Events"
keystroke "x" using {control down, shift down}
end telldelay 0.3tell application "System Events"
keystroke "p" using {command down, option down}
end tell
Finally, I assign a shortcut key to the script using such as Keyboard Maestro.