Trevor
Trevor

Reputation: 16116

NativeScript Static Library implementation how to generate TypeScript declarations

I struggling to implement a Captuvo static library as a plugin in NativeScript.

Plugin structure:

nativescript-captuvo-scan
    ├── package.json
    └── platforms
        └── ios
            └── include
                ├── captuvo
                │    ├── Captuvo.h
                │    └── module.modulemap
                │       
                └── libCaptuvoSDK.a

After adding the nativescript-captuvo-scan plugin to my project I am running the following commands in an attempt to expose the library as typescript typings.

$ TNS_DEBUG_METADATA_PATH="$(pwd)/metadata" tns build ios

and

$ TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios

Lots of d.ts files are generated in the project but I can't find a file exposing the library.

What am I missing, or where am I going wrong?

Does anyone know of a nativescript-plugin that wraps a static library? I can't seem to find an example out there that doesn't use a Podfile.

Upvotes: 1

Views: 1166

Answers (1)

Eddy Verbruggen
Eddy Verbruggen

Reputation: 3550

The folder structure is very important, but also the filenames. If you do it exactly like this, then NativeScript will correctly pick up your static iOS library:

folder structure

That CaptuvoSDK.d.ts is just a bonus: I generated TypeScript bindings for the Captuvo SDK by running these commands in the app's root folder:

  • TNS_DEBUG_METADATA_PATH="$(pwd)/metadata" tns build ios
  • TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios

Upvotes: 2

Related Questions