AppCode 2020.3 Help

Auto import

When you start using a class that is not yet imported, or a method from a library that is not yet included, AppCode will suggest adding the corresponding import statement automatically, or on code completion.

Import a missing header file

  1. Type a reference to a non-imported class or function.

  2. Press ⌥⏎. If there are multiple choices, select the desired option from the list.

    Auto import example

Automatically add import statements (in TypeScript)

In TypeScript files, AppCode can automatically add import statements if there is only one option to choose from.

  1. In the Preferences dialog ⌃⌥S, go to Editor | General | Auto Import | TypeScript/JavaScript.

  2. Select the Unambiguous imports on the fly checkbox and apply the changes.

When you paste blocks of code that contain references to the symbols that are not yet imported, AppCode will add missing imports automatically.

Disable import popups

When popups are disabled, unresolved references are underlined and marked with the red bulb icon the Quick-fix button. To view the list of suggestions, click this icon (or press ⌥⏎) and select Import class.

Disable all popups

  • Hover the mouse over the inspection widget in the top-right corner of the editor, click More, and disable the Show Auto-Import Tooltip option.

    Disable popups

Optimize imports

The Optimize Imports feature helps you remove unused imports and organize import statements in the current file or in all files in a directory at once according to the rules specified in Settings/Preferences | Editor | Code Style | <language> | Imports.

Optimize all imports

  1. Select a file or a directory in the Project tool window (View | Tool Windows | Project ).

  2. Do any of the following:

    • From the main menu, select Code | Optimize Imports (or press ⌃⌥O ).

    • From the context menu, select Optimize Imports.

  3. (If you've selected a directory) Choose whether you want to optimize imports in all files in the directory, or only in locally modified files (if yor project is under version control), and click Run.

Optimize imports in a single file

  1. Place the caret at the import statement and press ⌥⏎ or use the the Intention action button icon.

  2. Select Optimize imports.

Automatically optimize imports in modified files

If your project is under version control, you can instruct AppCode to optimize imports in modified files before committing them to VCS.

  1. From the main menu, select VCS | Commit (or press ⌃K ).

  2. Click Show Commit Options and in the Before commit area, select the Optimize imports checkbox.

Last modified: 08 March 2021