nativescript-cli icon indicating copy to clipboard operation
nativescript-cli copied to clipboard

feat: ability to embed NativeScript into host Swift and Kotlin projects

Open NathanWalker opened this issue 1 year ago • 0 comments

PR Checklist

  • [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages.
  • [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
  • [x] You have signed the CLA.
  • [x] All existing tests are passing: https://github.com/NativeScript/nativescript-cli/blob/master/CONTRIBUTING.md#contribute-to-the-code-base
  • [x] Tests for the changes are included.

What is the current behavior?

No easy way to embed NativeScript into host projects.

What is the new behavior?

You can use the cli to embed any project into Swift or Kotlin projects with the following:

ns embed ios /path/to/Swift/project

ns embed android /path/to/Kotlin/project <optional moduleName>

Also supported via nativescript.config.ts:

import { NativeScriptConfig } from "@nativescript/core";

export default {
  id: "org.nativescript.testembed",
  appPath: "app",
  appResourcesPath: "App_Resources",
  android: {
    v8Flags: "--expose_gc",
    markingMode: "none",
  },

  embed: {
    hostProjectPath: "./platforms/android",
    hostProjectModuleName: "TestEmbed",
    
    // or platform specific overrides:
    ios: {
      hostProjectPath: "./platforms/ios",
    },
    android: {
      hostProjectPath: "./platforms/android",
      hostProjectModuleName: "TestEmbed",
    },
  },
} as NativeScriptConfig;

NathanWalker avatar May 28 '24 17:05 NathanWalker