GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • NativeScript
  • Blog
  • Community
  • Support
  • Open NativeScript GitHub
  • Adding Native Code

This view

  • Original page
  • New address

GeezerVison is showing docs.nativescript.org — Adding custom native code to a project | NativeScript

NativeScript 9.1 Released → V8 14.9, Vite 8 HMR, built for rapid agentic visual iteration
Dig in→
  • Docs
  • Tutorials
  • Preview
  • Snacks
  • Plugins
  • UI Components
  • API Reference
  • Getting Started

    • Introduction
    • Environment Setup
      • Windows
      • macOS
      • Linux
    • Creating a Project
    • Choosing an editor
    • Troubleshooting
  • Development Workflow

    • CLI Basics
    • Running
    • Debugging
    • Publishing
    • Plugins
    • Recommended Plugins
    • Testing
    • Updating
      • To Latest
  • Project Structure

    • App_Resources/
    • src/
      • fonts/
      • app.css•scss
      • main.js•ts
    • nativescript.config.ts
    • package.json
    • references.d.ts
    • tsconfig.json
    • vite.config.mts
    • webpack.config.js
  • Configuration

    • Config Reference
    • Vite Reference
    • Vite Framework Flavors
    • Webpack Reference
  • Fundamental Concepts

    • Accessibility
    • Animations
    • Best Practices
    • Commonly Used APIs
      • @nativescript/core
        • Application
        • ApplicationSettings
        • Color
        • Connectivity
        • Device
        • FileSystem
        • FPS Meter
        • Http
        • ImageCache
        • Observable
        • Screen
        • Trace
        • Utils
        • XmlParser
    • Data Binding
    • Error Handling
    • Gestures
    • Navigation
      • Using Frames and Pages
      • Using Modals
    • Property System
    • Styling
  • Crash Reporting

    • Using Sentry
  • Developing with Vision Pro

    • Developing with visionOS
    • Previewing visionOS from StackBlitz
  • Agentic Coding

    • Leverage AI assistants
    • Using the Docs with AI
  • Advanced Concepts

    • Adding Native Code
      • Adding Java/Kotlin Code
      • Adding ObjectiveC/Swift Code
      • Generating TypeScript types
    • Extending Native Classes
      • Android
      • iOS
    • Create Custom Native Elements
    • Customizing View Elements
    • Shared Element Transitions
    • Multithreading
    • Multi-Window Development
    • Code Sharing
    • Metadata
    • Marshalling
      • iOS Marshalling
      • iOS Runtime Types
      • Android Marshalling
    • Hooks
    • Platform Version Handling
    • Widgets for iOS
Are you an LLM? You can read better optimized documentation at /guide/adding-native-code.md for this page in Markdown format

NativeScript provides direct access to all native APIs as well as cross-platform capabilities through @nativescript/core, third party plugins or @nativescript/* plugins. Additionally, you can easily add custom native files directly to your project and use them immediately from TypeScript.

Ever since NativeScript 8.8, you can use a single command to add platform language files and have them auto configured ready to use with:

bash
ns native add swift AwesomeClass
# Swift file 'nativescript-project/App_Resources/iOS/src/AwesomeClass.swift' generated successfully.

ns native add objective-c OtherAwesomeClass
# Module map 'nativescript-project/App_Resources/iOS/src/module.modulemap' has been updated with the header 'OtherAwesomeClass.h'.

ns native add kotlin com.company.AwesomeClass
# Kotlin file 'nativescript-project/App_Resources/Android/src/main/java/com/company/AwesomeClass.kt' generated successfully.

ns native add java com.company.OtherAwesomeClass
# Java file 'nativescript-project/App_Resources/Android/src/main/java/com/company/OtherAwesomeClass.java' generated successfully.
  1. You can also manually add native code to App_Resources:
    • Adding Java/Kotlin code to an application
    • Adding ObjectiveC/Swift Code to an application
  2. Optionally generate TypeScript types for the added APIs

Additionally, NativeScript also supports Jetpack Compose and SwiftUI through plugins.

  1. Jetpack Compose Plugin
    • Jetpack Compose Introduction and example
  2. SwiftUI Plugin
    • SwiftUI Introduction and example
Previous
←Using the Docs with AI
Next
Adding Java/Kotlin Code→
On this page

Contributors

OmbuwebNathanWalkerrigor789vallemarherefishyfish
Edit this page

Last updated:

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.