Guides

Capacitor

Last updated 25 November 2026

A Capacitor app is your web build plus two native projects. One run builds the web app, copies it in, and builds both the iOS app and the Android APK.

We ran this on 25 November 2026 on a fresh machine with our default image: a new Capacitor 8.6 app on top of a Vite web project, with the iOS and Android platforms added.

StepTime
npm run build and npx cap sync1s
xcodebuild, Release, unsigned12s
Install Java 21 with Homebrew28s
gradlew assembleRelease (first run downloads Gradle)36s

01The whole file

Capacitor projects keep ios/ and android/ in the repository, so there is nothing to generate. Save this as .macbuildcloud.yml, or paste it into Build steps on the Repositories page:

script:
  - npm ci
  - npm run build
  - npx cap sync
  - xcodebuild -project ios/App/App.xcodeproj -scheme App -configuration Release -destination "generic/platform=iOS" -derivedDataPath ios/build CODE_SIGNING_ALLOWED=NO -quiet build
  - HOMEBREW_NO_AUTO_UPDATE=1 brew install --quiet openjdk@21
  - export JAVA_HOME="$(brew --prefix openjdk@21)/libexec/openjdk.jdk/Contents/Home"
  - cd android && ./gradlew assembleRelease --no-daemon -q && cd ..
artifacts:
  - ios/build/Build/Products/Release-iphoneos/App.app
  - android/app/build/outputs/apk/release/*.apk
Every line runs in the same shell, one after the other, so JAVA_HOME set on one line is still set on the next. The artifacts are collected from wherever the last line leaves you, which is why the Android line ends with && cd ...

02Why the Java 21 lines

Capacitor 8's Android library needs Java 21. Our image has JDK 17, which Flutter and React Native use, and with it the Android build stops with invalid source release: 21. Installing Java 21 from Homebrew inside the build fixes that and took 28 seconds in our test. If you only build iOS, leave those two lines and the Android line out.

03Swift Package Manager or CocoaPods

Capacitor 8 sets up the iOS project with Swift Package Manager, so there is an App.xcodeproj and no Podfile, and nothing to install before xcodebuild. Projects created with older versions use CocoaPods instead: if your ios/App folder has a Podfile and an App.xcworkspace, run cd ios/App && pod install && cd ../.. first and build with -workspace ios/App/App.xcworkspace. We tested Capacitor 8.6.

04Signing

The iOS app above is unsigned and the APK comes out as app-release-unsigned.apk. For a signed .ipa and TestFlight, follow Code signing & TestFlight; the project is ios/App/App.xcodeproj and the scheme is App.


Something here wrong or missing? Tell us at support@macbuildcloud.com.