Skip to main content
On this page

Build and run iOS apps in VS Code on an iPhone or simulator

Switch schemes and configurations, pick an iPhone or a simulator, read build logs, and the ways to run.

Last updated

Build and run iOS apps in VS Code with the same keys as Xcode: Cmd+B builds, and Cmd+R builds and runs on an iPhone or the simulator, with the same result as pressing Run in Xcode. KXApp puts the scheme, configuration and run destination in the Xcode Project side bar view and the status bar, and errors go to the Problems panel. What you built in VS Code doesn't need rebuilding when you switch to Xcode.

The Xcode Project view in the activity bar is where everything starts. From top to bottom:

RowWhat it does
ProjectThe current project; click to switch when the folder has several. Right-click to open project settings or create an asset catalog
SchemeThe scheme to build and run, as defined in the project (shared and user schemes)
ConfigurationDebug, Release or a custom configuration; falls back to kxapp.defaultConfiguration
Run DestinationThe selected simulator or device
Devices & SimulatorsConnected devices and local simulators (grouped by OS version); click one to make it the run destination
TargetsThe project's targets; right-click to edit target settings or set the app icon from an image

The view's title bar has Build & Run, Build, Stop and Refresh Devices; its "…" menu has Clean Build Folder and Show Build Log. The status bar also has the scheme, run destination and a build button, so you can switch without opening the side bar.

How do I build an iOS app in VS Code?

Press Cmd+B or click the build button. Progress shows in the status bar, errors and warnings go to the Problems panel (click to jump to the line), and the full log is in Output › kxapp Build.

SettingDescription
kxapp.build.revealOutputShow the build log when a build starts
kxapp.build.extraArgsExtra arguments for every xcodebuild command, such as ["-quiet"]
kxapp.build.allowProvisioningUpdatesLet Xcode create or update provisioning profiles for device builds (on by default)

If a build looks wrong and you suspect stale products, use Clean Build Folder from the "…" menu, the same as Product › Clean Build Folder in Xcode.

How do I run on an iPhone or the simulator?

The list refreshes within seconds when you plug in or unplug an iPhone, or click Refresh Devices. Right-click a simulator to boot or shut it down; a selected simulator is booted automatically when you run. Devices are marked when they're on Wi-Fi or have Developer Mode off.

Running on a device needs the same things as in Xcode:

  • The device is unlocked, trusts this Mac and has Developer Mode on.
  • You're signed in with your Apple ID in Xcode › Settings › Accounts, and the project's signing settings can sign for this device.
  • Xcode has prepared the device (connect it once in Xcode's Devices and Simulators window).

What are the ways to run an iOS app from VS Code?

CommandShortcutWhat it does
Build & RunCmd+RBuilds, installs, launches and attaches the debugger
Run Without Debugging—Builds, installs and launches without the debugger; app output still goes to kxapp Console
Run Without Building—Installs the last build and starts debugging
StopCmd+.Ends the debug session and, by default, the app

When you build and run iOS apps in VS Code, Cmd+B and Cmd+R apply while the editor has focus and an Xcode project is open; then Cmd+B no longer toggles the side bar. Every other command is in the Command Palette under kxapp. For breakpoints, variables and the console see debug iOS apps on a real iPhone.

Frequently asked questions

Do I have to rebuild when I switch to Xcode?

No. The build cache is shared with Xcode, so a project you built in VS Code doesn't compile from scratch when you run it from Xcode.

Which file do I open for a CocoaPods project?

Open the project's folder. When a .xcworkspace and a .xcodeproj with the same name sit side by side, the extension uses the .xcworkspace. Run pod install in the project folder before building.

How do I add xcodebuild arguments to every build?

Put them in kxapp.build.extraArgs as an array, such as ["-quiet"]. Every xcodebuild command then includes them.

What if the build or code signing fails?

Start with the first error in the Problems panel and Output › kxapp Build. Signing errors usually mean signing in with your Apple ID in Xcode › Settings › Accounts and choosing a Team under the target's Signing & Capabilities. More cases are in common iOS build errors in VS Code.

Next steps