Skip to content
Latchkey

Ionic "capacitor build" with no platform added in CI

ionic capacitor build wraps Capacitor sync and a native build. It needs the target platform folder to exist. On a clean runner with gitignored native folders, the command fails because the platform was never added.

What this error means

ionic capacitor build android (or ios) stops because Capacitor cannot find the platform, often surfacing the underlying "Could not find the android platform" message.

Ionic
> capacitor sync android
[error] Could not find the android platform in: ./android
        Try running: npx cap add android

Common causes

The platform was never added on the runner

ionic capacitor build assumes ./android or ./ios exists. If those folders are gitignored and ionic capacitor add was not run, there is nothing to build.

Building a platform the runner cannot host

Attempting ionic capacitor build ios on a Linux runner cannot work because iOS requires macOS and Xcode.

How to fix it

Add the platform before building

  1. Run ionic capacitor add android (or ios) once dependencies are installed.
  2. Build the web app, then run ionic capacitor build.
  3. Use a macOS runner for ios.
.github/workflows/ci.yml
- run: npm ci && ionic build
- run: ionic capacitor add android
- run: ionic capacitor build android --no-open

Commit native folders instead

If you prefer to keep native folders in git, stop ignoring them so they are present on checkout and add is not needed.

How to prevent it

  • Add each native platform before ionic capacitor build.
  • Build iOS only on macOS runners.
  • Be consistent about committing or regenerating native folders.

Frequently asked questions

What causes ""ionic capacitor build" no platform"?
ionic capacitor build assumes ./android or ./ios exists. If those folders are gitignored and ionic capacitor add was not run, there is nothing to build.
How do I fix "ionic capacitor build" no platform?
Add the platform before building

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card