AppCode 2021.2 Help

Cling

AppCode integrates with Cling, an interactive C++ interpreter built on top of Clang and LLVM. Cling allows you to run code without building the project, which can be especially useful for prototyping and learning C++. See the short Cling basics video.

Install Cling

  1. Download the Cling executable for your OS or install it using the following brew command: brew install cling.

  2. In AppCode, go to Preferences | Languages & Frameworks | C/C++ | Cling.

    If Cling is presented in the system PATH, AppCode will detect it automatically. Otherwise, provide the path in the field.

    Path to cling executable

Use Cling to interpret code

  • You can call Cling-related actions from Tools | Cling on the main menu or via Help | Find Action (⌃ ⇧ A).

    Cling actions menu
  • To send a line or selection to the Cling session, click the bulb icon (or press ⌥ ⏎) on the desired piece of code:

    Cling intention
  • Another option is to type code directly in the Cling terminal.

Working directory for a Cling session

  • If there is a file currently opened in the editor, its directory is used as a working directory for Cling. Related include paths from this file work as well when sent to the same session.

  • Otherwise, AppCode uses the project root.

  • If there is no project, the home directory is used.

Cling terminal

Upon any of the Cling actions, AppCode opens the dedicated terminal window.

You can type code in this window and also load the current file or reset/close the session using the toolbar buttons.

Cling terminal

    Current issues and limitations

    • Adding extra arguments to the Cling executable from within AppCode is not available.

    • The Cling session is started within the project directory or within the home directory (if no project is currently open). The relative paths might not be handled correctly when sending a current line to Cling from a file that is not in the project root.

    Last modified: 21 July 2021