Preview a view of SwiftUI from AppCode

Ryoichi Izumita
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.

  1. Open preferences of AppCode.
  2. Tools -> External Tools
  3. Create an external tool.
  4. Input… Name: Xcode, Program: open Arguments: -a Xcode $FilePath$, WorkingDirectory: $ProjectFileDir$
  5. Open Keymap pref view.
  6. 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 tell
delay 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.

--

--