Error in Transpilation of iOS Delegate in NativeScript (Variable __metadata Not Found)

I'm facing an issue while trying to incorporate an iOS delegate in a NativeScript plugin. The error I'm encountering reads as follows:

Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: __metadata

The original code snippet is as below:

@ObjCClass(SQRDCheckoutControllerDelegate)
export class SquareReader extends NSObject implements SQRDCheckoutControllerDelegate { 
/* 
iOS delegate implementation here 
   (source https://docs.connect.squareup.com/payments/readersdk/setup-ios) 
*/
 }

Upon transpiling, the code reduces down to:

SquareReader = __decorate([
     ObjCClass(exports.SQRDCheckoutControllerDelegate),
     __metadata("design:paramtypes", [])
], SquareReader);

If I remove the __metadata line, a different error surfaces:

Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Error: Protocol "undefined" is not a protocol object.

Any suggestions on how to tackle this? I've come across instances like nativescript-image-swipe, where the code transpiles successfully without using the __metadata method, raising suspicions on the transpilation process.

Answer №1

To resolve the issue, I decided to tidy up my typings by re-running the command to generate them:

TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios
. Afterwards, I stored the typings in the /src directory for my plugin. Once the typings were corrected, the project operated smoothly and the Delegate functioned flawlessly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transforming a typical JSON file into a parent-child hierarchical JSON structure similar to the one utilized in d3's flare.json file format

My JSON file has a specific structure: { "a": "b", "c": "d", "e": { "f": "g", "h": "i" } } I want to transform it into the following structure: { "name": "Root", "parent": "null", "children": [ { ...

Determine when a UIView in iOS using Swift is being hovered over

Currently working on developing an iOS Swift 2 app and seeking a way to display a subview for a specific duration when the parent view is interacted with using touch. As an illustration, there is a UIView in my app that plays videos. The goal is to have a ...

A guide on leveraging typeof within function parameters to ensure accurate variances

Let's create a simple class hierarchy and a list of instances. The goal is to filter items from the list of instances based on their class. There are a couple of challenges: We cannot use the typeof T syntax. How can this be written? We cannot decla ...

Troubleshooting: Issue with Custom Segue Animation

I have a customized class designed for a unique segue animation. I am attempting to create a custom tap gesture animation. Within my storyboard layout, there is a Navigation Controller, the primary view, and two additional views. I have linked the gesture ...

Can you explain the distinctions among the accessible, accessibilityLabel, and accessibilityHint properties of the Text component in React Native?

Can you explain the distinctions among the accessible, accessibilityLabel, and accessibilityHint properties of the Text component in react native? The information provided in the React Native documentation is insufficient. It would be helpful to see some ...

What is the best way to convert Angular form data into a POST request that the server can process?

In search of a solution to properly send data to the server in a format that it can accept. Currently, the title and descriptions are being successfully transmitted but the ratings are not coming through. It should be noted that there will be more than two ...

Using Angular's filter pipe to search within a nested array

We are attempting to implement an angular pipe for filtering a list of sub-items, with the goal of removing parent items if there are no child items present. Here is the HTML code snippet we are using: <div class="row border-bottom item" *n ...

"Troubleshooting the issue of React Native image picker failing to upload images on iOS

I am encountering difficulties with uploading an image using fetch and react-native-image-picker to Multer and Express backend. Here is the snippet of my React Native code: try { const data = new FormData(); data.append('image', { name: ...

Comparing the MVC Design Pattern in .Net Core to Express.js

I have recently started learning about Node.js and Express.js, and I am looking for guidance on how to incorporate the MVC pattern into my project. I want to follow the same structure as .Net Core projects, with separate sections for models, controllers, ...

How can I create a page similar to the album page on iTunes?

I am attempting to create a layout similar to the iTunes album page using uitableviewcontroller. However, I feel like I may be heading in the wrong direction. My current approach involves making modifications in tableView:cellForRowAtIndexPath:. If indexP ...

What is the best way to pass down SectionList prop types in TypeScript when using React?

I am working on creating a wrapper for SectionList in React Native that needs to accept all the standard props of SectionList along with some custom ones. How can I set up typescript to accommodate this? Here is what I have tried: import React from &apos ...

TypeScript multi-dimensional array type declaration

I currently have an array that looks like this: handlers: string[][] For example, it contains: [["click", "inc"], ["mousedown", "dec"]] Now, I want to restructure it to look like this: [[{ handler: "click" ...

When using Typescript, you may encounter the error message "Declaration file for module 'xmlhttprequest' not found."

When trying to use the following code on Node: import { XMLHttpRequest } from 'xmlhttprequest'; I encountered the following error while compiling with tsc: index.ts|4 col 32 error| 7016[QF available]: Could not find a declaration file for mo ...

Retrieve an array of specific column values from an array of objects using Typescript

How can I extract an array from an array of objects? Data var result1 = [ {id:1, name:'Sandra', type:'user', username:'sandra'}, {id:2, name:'John', type:'admin', username:'johnny2'}, ...

Utilizing query parameters in JavaScript

When querying data from the database using passed parameters, I encountered an issue. For example: http://localhost:3030/people?$skip=0&$limit=25&$sort[name]=0&description[$name]=rajiv I wanted to add an extra parameter without including it in ...

What is the solution for resolving the error occurring in the Ionic template for chatRoom?

I have successfully created a room messaging chat with Ionic Angular, but I am facing an issue with the display of message rows. When displaying messages from other users, all columns show in the same row, but for my own messages, the logo appears at the t ...

TSLint has detected an error: the name 'Observable' has been shadowed

When I run tslint, I am encountering an error that was not present before. It reads as follows: ERROR: C:/...path..to../observable-debug-operator.ts[27, 13]: Shadowed name: 'Observable' I recently implemented a debug operator to my Observable b ...

What exactly is the Scene Dock feature in Apple's Date Cell Demo?

I have been exploring Apple's Date Cell example project and I am curious about the additional items present in the Scene Dock of MyTableViewController, such as the Picker and Done elements. How are these items placed next to First Responder, Exit, and ...

What causes the EXC_BAD_ACCESS error to be thrown by SKProductsRequestDelegate/SKRequestDelegate when encountering an NSError?

Utilizing SKProductsRequest to retrieve product information from the App Store is resulting in issues. When simulating a loss of connectivity on my device, the request fails and ultimately causes my app to crash within the SKRequestDelegate when attempting ...

There seems to be an issue in RCTBatchedBridge.m with an error message stating that the data message is invalid and must all be of a

While attempting to authorize using the react-native-oauth library, an error is encountered (refer to the red image at the bottom). Extensive research only led to this unanswered question that seems similar. Upon examining the source code, it was discovere ...