AppCode 2023.1 Help

Code editing

Completion

The table below shows key similarities and differences between code completion in Xcode and AppCode:

Feature

Xcode

AppCode

Comments

Case sensitivity

Case-insensitive by default

Case-sensitive by default

Can be changed in Settings | Editor | General | Code Completion

Shortcut

Esc or ⌃Space

Ctrl+Space

Fuzzy matching

Supported

Supported

Jump to next CamelCase using Tab

Supported

Not supported

There are several additional completion types that can help you code faster. Lear more about them in the Code completion section.

Code selection

Of course, you can select code with the mouse as usual. AppCode also has several specific code selection mechanisms which you can adapt to edit code faster:

  • Multiple selections: press Ctrl+Alt+Shift+J to select all occurrences of the currently selected text, or select the text and press Alt+J to select its occurrences one by one. Next, you can change them simultaneously. This way you can achieve a behavior similar to Xcode’s Edit all in Scope.

  • Column selection: press Alt+Shift+Insert, select several lines, and edit the text as columns. Press Alt+Shift+Insert to exit this mode.

  • Structural selection: this allows you to select not text but code, while taking advantage of the code hierarchy. Set your cursor anywhere in the code and press Ctrl+W / Ctrl+Shift+W.

Snippets

In Xcode, you can configure code snippets with placeholders for template values. In AppCode, such snippets are called live templates and they allow more interaction, such as scripting the placeholder values, setting default values depending on the context, and more. All the built-in templates can be found in Settings | Editor | Live Templates.

Formatting

In Xcode, you format code with ⌃I (to reindent it), and this works only for the current file. In AppCode you can:

The Reformat code action takes into account many more code style settings than the Auto-indent lines action does, and it can be applied to a specific directory, file, or the whole project.

You can configure specific code style settings separately for each language supported by AppCode in Settings | Editor | Code style:

Code style settings

Documentation

AppCode fetches the documentation from Xcode docsets. You can view it with Ctrl+Q. It also allows you to use external documentation browsers such as Dash.

To use Dash instead of the bundled browser, enable it in Settings | Editor | External Documentation | Dash and use the Shift+F1 shortcut.

In Xcode, Open Quickly ⇧⌘O lets you navigate to a file, symbol, or class. In AppCode, you can use Search Everywhere (double Shift) for the same purpose, or use Go to by Number/Mnemonic Ctrl+N, Go to Symbol Ctrl+Alt+Shift+N, or Go to File Ctrl+Shift+N as appropriate.

Actions menu

In Xcode, most code generation actions are available via Ctrl+Click, as are refactorings, code folding options, and others. AppCode is much more about using keyboard shortcuts for different actions because they can help you code more efficiently:

  • To see what refactorings can be applied to the currently selected code, use Refactor This Ctrl+Alt+Shift+T. Each individual refactoring can also be called up with its own shortcut. To remember them, consider using Ctrl+Alt+mnemonic, for example, Ctrl+Alt+M is for Extract Method and Ctrl+Alt+V is for Extract Variable.

  • Code generation actions are available via Generate Alt+Insert, Override Ctrl+O, Implement Ctrl+I, or Alt+Enter (via quick-fixes and intention actions).

  • Code folding actions have separate shortcuts for folding various code constructs.

AppCode’s refactorings and code generation actions always work in the code context: they understand what you’re probably looking for to apply to where your cursor is at the moment, and they suggest only relevant and applicable action choices.

Documentation generation

To generate comment stubs in AppCode, type the beginning of the comment and press Enter.

Create Swift comments

Refactorings

AppCode has refactorings available for each language it supports, including HTML and JavaScript. Objective-C/C/C++ has a large set of Extract refactorings (for methods, variables, blocks, categories parameters, and more), together with Rename, Move, and Subclass/Superclass:

Objective-C refactorings

Change Signature can take care of changing the function or method signature everywhere in your code.

Swift refactorings work both in mixed-code projects and in pure Swift code. They can extract methods, closures, and variables:

Swift refactorings

AppCode’s refactorings, as well as its code generation actions, don’t work with text – they work with code structures to be as accurate as possible. Moreover, global refactorings update all the occurrences in your project.

Generation

Code generation actions in AppCode are available via Alt+Insert. The set of actions is different for Swift and Objective-C:

Swift

Objective-C

Code generation in Swift
Code generation in Objective-C

Folding

Code folding in AppCode can be configured in Settings | Editor | General | Code Folding. To fold a code block, use one of the following:

  • Press Ctrl+NumPad -/Ctrl+NumPad + to collapse/expand the current code block.

    code folding
  • Collapse/expand the code block by clicking the -/+ icons on the gutter.

  • Press Ctrl+Alt+NumPad +/Ctrl+Alt+NumPad - to collapse/expand all the code in your file recursively.

  • Use Ctrl+Shift+. to fold an if, else, switch, and other control flow statements.

Fix-its, intentions, and inspections

Xcode shows most errors and warnings inline in the code editor. However, the full set of code analysis checks in Xcode, which is available via Product | Analyze, requires the project to be built, and works correctly only if the project has been built successfully.

AppCode performs all of its code analysis checks on the fly, and, even better, it does not require you to build the project at all. It integrates all the CLang analyzer checks for Objective-C and all the SourceKit checks for Swift, together with fix-its. In AppCode, these checks are called inspections.

AppCode has inspections for all the languages it supports, not limited to Objective-C, Swift, and C/C++. For Objective-C/C/C++ and Swift, it has separate specific sets of inspections which you can view in Settings | Editor | Inspections | Objective-C/C/C++ (or Swift):

Inspections for Objective-C

Each language supported by AppCode can have its own set of inspections. Some plugins, such as Database Tools and SQL, already come bundled with the IDE. For others, all you need to do is to install the plugin for the language, and all inspections for it will become available in Settings | Editor | Inspections. All the inspections from third-party plugins that provide specific code analysis checks such as SwiftLint are also available here.

SwiftLint inspection

For any inspection, you can set the severity, or disable/enable it as appropriate. You can also create your own inspection profile and share it with your teammates.

In addition to inspections that alert you to a problem in your code, AppCode has so-called intentions actions which provide ways to optimize your code:

Apply intention action

All intentions in AppCode can be configured in Settings | Editor | Intentions:

Intentions settings

Inspecting

The Inspect Code action is AppCode’s replacement for Xcode’s Analyze. In AppCode, this action runs all inspections available for a particular language for the scope you need.

After the check is completed, you can apply the inspection quick-fix to several places at once:

Inspection results tool window

You can run a single inspection by using Run Inspection by Name Ctrl+Alt+Shift+I.

Last modified: 17 January 2023