Installing @nativescript/capacitor
Version note
8.x works with Capacitor 8 apps on iOS and Android (on iOS, Capacitor 6/7 apps must use SPM mode).
Using CocoaPods? Use @nativescript/capacitor@5 and the v5 docs.
- iOS: no CocoaPods, no Podfile edits, no AppDelegate changes, no Xcode build phases, no linker flags. The NativeScript runtime arrives as a Swift Package (NativeScript/ios-spm) when Capacitor syncs the plugin, and platform API metadata ships inside the runtime's framework with zero configuration.
- Android: no
Applicationreplacement, no manifest edits, nobuild.gradlegrafting, nothing copied into your repo. The plugin is a self-contained Gradle module that Capacitor wires up on sync;nscap buildfetches the runtime once (cached) and generates platform metadata automatically.
1. Start from a Capacitor app
Follow the Ionic or Capacitor getting started guide, and make sure your platforms are added:
npx cap add ios
npx cap add android2. Install and initialize
npm install @nativescript/capacitor
npx nscap initnscap init is additive and idempotent — it only creates files and npm scripts, never touching your Xcode project:
src/nativescript/index.ts— your native TypeScript entry, with a working native modal examplesrc/native-custom.d.ts— strongly type your ownnative.*helpers- npm scripts that wire
nscap buildinto Capacitor'scapacitor:copy:beforehook, so your native code builds automatically on everynpx cap copy/npx cap sync
3. Build and run
npm run build # build your web assets as usual (any bundler)
npx cap sync
npx cap run ios # and/or: npx cap run androidThat's the entire setup. At app launch you'll see the example's greeting in the native console, and from your web code you can immediately do:
import { native } from '@nativescript/capacitor';
const version = await native.UIDevice.currentDevice.systemVersion.get;
native.openNativeModalView(); // the scaffolded example helperRequirements
- Capacitor 8 app (on iOS, SPM is the Capacitor 8 default — or Capacitor 6/7 with SPM mode)
- iOS 15+, Xcode with the iOS SDK
- Android minSdk 23+, Android SDK, JDK 17+
- Node 18+
Troubleshooting
Blank webview after adding NativeScript
If the app launches to a blank screen, your web assets were likely never built — run your web build (e.g. npm run build) before npx cap sync. The NativeScript build hook creates the web assets folder, which can mask Capacitor's usual "web assets directory not found" error on brand-new apps.
Where do my NativeScript console.logs go?
To the native system log, not the webview console. On iOS, see them in the Xcode console, or:
# iOS simulator
xcrun simctl spawn booted log stream --predicate 'process == "App"'On Android they appear in logcat under the JS tag:
adb logcat -s JSFirst build is slow
The very first iOS build downloads the NativeScript runtime binaries through Swift Package Manager, and the first nscap build with an Android platform fetches the Android runtime once. Both are cached; subsequent builds are fast.
