Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


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

    Nathan WalkerNathan Walker

    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.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    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.

    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.

    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.

    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.

    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.