Capacitor CLI provides comprehensive cross-platform operations for adding, building, and managing iOS and Android projects through command-line interfaces. Platform-specific operations are handled internally and are not exposed as exportable functions.
Add native platform projects to a Capacitor app.
Command:
npx cap add [platform]Options:
--packagemanager <packageManager> - Package manager for dependency installs (CocoaPods or SPM for iOS)Examples:
# Add iOS platform
npx cap add ios
# Add Android platform
npx cap add android
# Add iOS with Swift Package Manager
npx cap add ios --packagemanager SPMUpdate native plugins and dependencies based on package.json.
Command:
npx cap update [platform]Options:
--deployment - Use deployment option for pod install (iOS)Examples:
# Update all platforms
npx cap update
# Update specific platform
npx cap update ios
# Update with deployment flag
npx cap update ios --deploymentBuild the release version of the selected platform.
Command:
npx cap build <platform>Platform-specific Options:
iOS Build Options:
--scheme <schemeToBuild> - iOS Scheme to build--configuration <name> - Configuration name of the iOS Scheme--xcode-team-id <xcodeTeamID> - Developer team for building and exporting--xcode-export-method <method> - Export method (app-store-connect, release-testing, etc.)--xcode-signing-style <style> - Signing style (automatic or manual)--xcode-signing-certificate <cert> - Certificate name or SHA-1 hash--xcode-provisioning-profile <profile> - Provisioning profile name or UUIDAndroid Build Options:
--flavor <flavorToBuild> - Android Flavor to build--keystorepath <keystorePath> - Path to the keystore--keystorepass <keystorePass> - Password to the keystore--keystorealias <keystoreAlias> - Key Alias in the keystore--keystorealiaspass <keystoreAliasPass> - Password for the Key Alias--androidreleasetype <type> - Release type: APK or AAB--signing-type <signingtype> - Program used to sign apps (apksigner or jarsigner)Examples:
# Build Android APK
npx cap build android --androidreleasetype APK
# Build iOS with specific scheme and configuration
npx cap build ios --scheme MyAppScheme --configuration Release
# Build Android with keystore signing
npx cap build android \
--keystorepath /path/to/keystore.jks \
--keystorepass mypassword \
--keystorealias myalias \
--keystorealiaspass aliaspasswordRun sync, then build and deploy the native app on device or emulator.
Command:
npx cap run [platform]Options:
--scheme <schemeName> - Set the scheme of the iOS project--flavor <flavorName> - Set the flavor of the Android project--list - List available targets, then quit--target <id> - Use a specific target--no-sync - Do not run sync before building--forwardPorts <port:port> - Automatically run "adb reverse" for live-reloading (Android)-l, --live-reload - Enable Live Reload--host <host> - Host used for live reload--port <port> - Port used for live reload--configuration <name> - Configuration name of the iOS SchemeExamples:
# Run on iOS device with live reload
npx cap run ios --live-reload --host 192.168.1.100
# List available Android targets
npx cap run android --list
# Run on specific iOS simulator
npx cap run ios --target "iPhone 15 Pro"
# Run Android with specific flavor
npx cap run android --flavor debugOpen the native project workspace in the appropriate IDE.
Command:
npx cap open [platform]Examples:
# Open iOS project in Xcode
npx cap open ios
# Open Android project in Android Studio
npx cap open androidPlatform operations are implemented through internal modules that are not exported from the CLI package:
/android/ module functions/ios/ module functions/common utilitiesThese internal functions are called by the CLI commands but are not part of the public API.