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.


    Prepare for native iOS and Android api intellisense with NativeScript

    Nathan WalkerNathan Walker

    To prepare your development environment to code against native apis such as Objective C, Swift and Java, let's learn how to install tns-platform-declarations to provide rich intellisense support for all the native iOS and Android api’s. This lesson will cover how to modify your tsconfig.json and references.d.ts properly to ensure working with native api’s is smooth and as helpful as possible.



    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




    Let's install the tns-platform-declarations, and let's save that to our devDependencies. Now we need to make a few modifications to our tsconfig. Let's reference the ES2016 library and then modify our references.

    NativeScript's core engineering team has provided some excellent examples on great project setup, and we'll use their references here and we'll set these up. You can see it references ES2016 tns-core-modules in the iOS and Android platform declarations. With this installed, you now get rich IntelliSense support on things like UI application, the shared application instance, key window.

    And in fact, you can go to Apple's API reference documentation and just browse the API that's now opened up to you. You'll find a rich set of classes in APIs. Things like NSNotificationCenter, where you can grab an instance of the default center and actually send events out -- which is kind of like Objective-C's EventBus system -- and access the APIs from, for instance, UI kit, which provides a rich API to say, for instance, the UI video controller.

    And just like you can browse Apple's API reference for Objective-C, you can browse Android's API reference for Android, where you have access to things like the Android Media Package -- where you can get access to the media player -- or Android's location package, where you have access to things like the Geocoder.

    Having this setup will help you dramatically in coding against native APIs, be it for iOS or Android.