⚠️ This lesson is retired and might contain outdated information.

Generate metadata TypeScript declarations for Objective C/Swift libraries on iOS

Nathan Walker
InstructorNathan Walker
Share this video with your friends

Social Share Links

Send Tweet

Learn how to generate TypeScript declaration files for all native api’s for iOS, including any 3rd party Objective C/Swift libraries included in your project via Cocoapods or other means. This will allow you to view all the metadata for included iOS libraries to see what classes and apis are exposed to NativeScript.

[00:00] You can specify TNS_TypeScript_declarations_path, and this is going to equal a location to actually print out all the metadata for all the classes that are available. We're going to use a standard shell script variable for the present working directory.

[00:20] We'll just name this folder typingz with a Z, because some people do use typings with an S as a standard to put custom typings. Then we'll pass tns build ios. Now, if we go look in our project, we will see a typingz with a Z i386, and an x86 64 folder.

[00:40] We can take a look inside, and we have typescript definition files generated for all the metadata from Objective-C classes, but what is nice about this, is you will also get any third-party Objective-C libraries metadata generated.

[00:54] For instance, here is the Filestack API that we have included in our project now through the CocoaPod. We can scroll through this and actually see all the definitions of the classes which are made available by including that CocoaPod.

[01:09] This can be extremely useful when you're trying to see what is exposed and/or discrepancies between property names that may be indicated in the documentation for a pod, versus what the API actually exposes.