CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tns-platform-declarations

Platform-specific TypeScript declarations for NativeScript for accessing native objects

84

1.23x
Overview
Eval results
Files

ios-platform.mddocs/

iOS Platform

Complete iOS SDK framework declarations providing access to all iOS frameworks, native memory management utilities, and Objective-C runtime integration. Covers 139 iOS frameworks from ARKit to WebKit.

Capabilities

iOS Entry Point

Single entry point providing access to all iOS SDK frameworks and runtime functions.

/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />

Core iOS Runtime Functions

Essential runtime functions for iOS development and native object management.

/**  
 * Trigger garbage collection in JavaScript
 */
declare function __collect(): void;

/**
 * Release the reference to the wrapped native Objective-C object
 * @param object - The Objective-C object to release
 */
declare function __releaseNativeCounterpart(object: NSObject): void;

/**
 * Get accurate system timestamp in milliseconds
 * @returns Current system time in milliseconds
 */
declare function __time(): Number;

Usage Examples:

// Create and manage NSObject instances
const nsString = new NSString("Hello iOS");
// ... use the object
__releaseNativeCounterpart(nsString); // Release when done

// Get high-precision timestamp
const timestamp = __time();
console.log(`Current time: ${timestamp}`);

// Trigger garbage collection
__collect();

iOS Framework Declarations

Comprehensive type definitions for all iOS SDK frameworks. Each framework is provided as a separate declaration file.

// Core frameworks (sample - 139 total frameworks available)
/// <reference path="objc-x86_64/objc!Foundation.d.ts" />
/// <reference path="objc-x86_64/objc!UIKit.d.ts" />
/// <reference path="objc-x86_64/objc!CoreFoundation.d.ts" />
/// <reference path="objc-x86_64/objc!CoreGraphics.d.ts" />
/// <reference path="objc-x86_64/objc!AVFoundation.d.ts" />
/// <reference path="objc-x86_64/objc!CoreData.d.ts" />
/// <reference path="objc-x86_64/objc!CoreLocation.d.ts" />
/// <reference path="objc-x86_64/objc!CoreMotion.d.ts" />
/// <reference path="objc-x86_64/objc!MapKit.d.ts" />
/// <reference path="objc-x86_64/objc!StoreKit.d.ts" />

// Media and graphics frameworks
/// <reference path="objc-x86_64/objc!ARKit.d.ts" />
/// <reference path="objc-x86_64/objc!AVKit.d.ts" />
/// <reference path="objc-x86_64/objc!CoreImage.d.ts" />
/// <reference path="objc-x86_64/objc!CoreMedia.d.ts" />
/// <reference path="objc-x86_64/objc!CoreVideo.d.ts" />
/// <reference path="objc-x86_64/objc!GameplayKit.d.ts" />
/// <reference path="objc-x86_64/objc!Metal.d.ts" />
/// <reference path="objc-x86_64/objc!SpriteKit.d.ts" />

// System and utility frameworks  
/// <reference path="objc-x86_64/objc!Accelerate.d.ts" />
/// <reference path="objc-x86_64/objc!CloudKit.d.ts" />
/// <reference path="objc-x86_64/objc!CoreML.d.ts" />
/// <reference path="objc-x86_64/objc!CryptoTokenKit.d.ts" />
/// <reference path="objc-x86_64/objc!EventKit.d.ts" />
/// <reference path="objc-x86_64/objc!HealthKit.d.ts" />
/// <reference path="objc-x86_64/objc!HomeKit.d.ts" />
/// <reference path="objc-x86_64/objc!LocalAuthentication.d.ts" />
/// <reference path="objc-x86_64/objc!MultipeerConnectivity.d.ts" />
/// <reference path="objc-x86_64/objc!NetworkExtension.d.ts" />
/// <reference path="objc-x86_64/objc!NotificationCenter.d.ts" />
/// <reference path="objc-x86_64/objc!PassKit.d.ts" />
/// <reference path="objc-x86_64/objc!PushKit.d.ts" />
/// <reference path="objc-x86_64/objc!QuickLook.d.ts" />
/// <reference path="objc-x86_64/objc!SafariServices.d.ts" />
/// <reference path="objc-x86_64/objc!Security.d.ts" />
/// <reference path="objc-x86_64/objc!Social.d.ts" />
/// <reference path="objc-x86_64/objc!WatchConnectivity.d.ts" />
/// <reference path="objc-x86_64/objc!WebKit.d.ts" />

// And 110+ additional iOS frameworks...

Usage Examples:

// All frameworks are available automatically when using ios.d.ts
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />

// Use Foundation framework
const nsString = NSString.stringWithString("Hello World");
const nsArray = NSMutableArray.alloc().init();

// Use UIKit framework
const alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(
  "Alert", 
  "This is an alert", 
  UIAlertControllerStyle.Alert
);

// Use Core Location
const locationManager = CLLocationManager.alloc().init();
locationManager.requestWhenInUseAuthorization();

// Use AVFoundation  
const audioSession = AVAudioSession.sharedInstance();

Complete Framework Coverage

TNS Platform Declarations includes type definitions for all major iOS frameworks:

Core System Frameworks:

  • Foundation - Core classes and data types
  • UIKit - User interface components
  • CoreFoundation - Low-level C APIs
  • CoreGraphics - 2D graphics and imaging
  • CoreData - Data persistence framework
  • CoreServices - Essential system services

Media and Graphics:

  • AVFoundation - Audio and video media framework
  • AVKit - Media playback user interface
  • CoreImage - Image processing and analysis
  • CoreMedia - Low-level media types and functions
  • CoreVideo - Video processing pipeline
  • Metal - GPU-accelerated graphics and compute
  • ARKit - Augmented reality framework
  • SpriteKit - 2D game development

Networking and Communication:

  • CFNetwork - Network services and protocols
  • NetworkExtension - Network extension apps
  • MultipeerConnectivity - Peer-to-peer connectivity
  • WatchConnectivity - Apple Watch communication

Device and Sensors:

  • CoreLocation - Location and heading services
  • CoreMotion - Motion and environment sensing
  • CoreBluetooth - Bluetooth Low Energy communication
  • HealthKit - Health and fitness data
  • HomeKit - Home automation framework

Business and Productivity:

  • EventKit - Calendar and reminder data
  • Contacts - Contact information access
  • AddressBook - Legacy contact framework
  • PassKit - Apple Pay and wallet functionality
  • StoreKit - In-app purchases and subscriptions

Security and Authentication:

  • Security - Cryptographic services
  • LocalAuthentication - Biometric authentication
  • CryptoTokenKit - Cryptographic token interface
  • KeychainServices - Secure credential storage

Development and Debugging:

  • os - Unified logging system
  • Darwin - Low-level Darwin interfaces
  • Dispatch - Grand Central Dispatch

Complete iOS Framework Catalog

TNS Platform Declarations includes 139 iOS framework declaration files. Here's the complete catalog organized by category:

Core System Frameworks (18 frameworks):

  • Foundation, UIKit, CoreFoundation, CoreGraphics, CoreServices, CoreData
  • CFNetwork, Dispatch, Darwin, QuartzCore, os, ObjectiveC
  • CoreText, ImageIO, MobileCoreServices, SystemConfiguration, UniformTypeIdentifiers, OSLog

Media and Graphics (24 frameworks):

  • AVFoundation, AVKit, CoreImage, CoreMedia, CoreVideo, CoreAudio, AudioToolbox
  • VideoToolbox, CoreAnimation, Metal, MetalKit, MetalPerformanceShaders
  • ARKit, RealityKit, SpriteKit, SceneKit, GameplayKit, ReplayKit
  • Photos, PhotosUI, AssetsLibrary, MediaPlayer, MediaToolbox, CoreML, Vision

Networking and Communication (12 frameworks):

  • CFNetwork, NetworkExtension, Network, MultipeerConnectivity, WatchConnectivity
  • CallKit, PushKit, UserNotifications, BackgroundTasks, Combine, WebKit, SafariServices

Device and Sensors (18 frameworks):

  • CoreLocation, CoreMotion, CoreBluetooth, HealthKit, HomeKit, CoreTelephony
  • ExternalAccessory, GameController, CoreHaptics, DeviceCheck, SensorKit
  • ProximityReader, AccessibilityUIKit, VisionKit, NaturalLanguage, Speech, SoundAnalysis, Intents

Business and Productivity (15 frameworks):

  • EventKit, EventKitUI, Contacts, ContactsUI, AddressBook, AddressBookUI
  • PassKit, StoreKit, MessageUI, MailKit, QuickLook, FileProvider
  • DocumentCloud, UniformTypeIdentifiers, LinkPresentation

Security and Authentication (8 frameworks):

  • Security, LocalAuthentication, CryptoTokenKit, AuthenticationServices
  • CryptoKit, KeychainServices, AppTrackingTransparency, AdSupport

User Interface and Experience (22 frameworks):

  • UIKit, SwiftUI, AppKit, WatchKit, TVUIKit, CarPlay, WidgetKit
  • NotificationCenter, UserNotifications, UserNotificationsUI, PencilKit
  • PDFKit, QuickLookThumbnailing, MessageUI, Social, CloudKit
  • CoreSpotlight, Intents, IntentsUI, ActivityKit, ScreenTime, FamilyControls

Machine Learning and AI (8 frameworks):

  • CoreML, Vision, NaturalLanguage, Speech, SoundAnalysis, CreateML, TabularData, RealityFoundation

Development and Debugging (14 frameworks):

  • XCTest, OSLog, MetricKit, Instruments, DeveloperToolsSupport
  • SwiftDocC, SwiftDocCPlugin, PackageDescription, ArgumentParser
  • Collections, Algorithms, AsyncAlgorithms, RegexBuilder, _Concurrency

Memory Management

iOS platform declarations support both manual and automatic memory management:

// Manual memory management
const nsObject = NSObject.alloc().init();
try {
  // Use the object...
} finally {
  __releaseNativeCounterpart(nsObject);
}

// Automatic memory management (recommended)  
const autoString = NSString.stringWithString("Auto-managed");
// No manual release needed

// Garbage collection
__collect();

Framework Usage Patterns

Foundation Framework Usage

// String operations
const str = NSString.stringWithString("Hello");
const uppercaseStr = str.uppercaseString;

// Array operations
const array = NSMutableArray.alloc().init();
array.addObject("Item 1");
array.addObject("Item 2");

// Dictionary operations
const dict = NSMutableDictionary.alloc().init();
dict.setObjectForKey("value", "key");

UIKit Framework Usage

// View controller
const viewController = UIViewController.alloc().init();
viewController.title = "My View";

// Alert controller
const alert = UIAlertController.alertControllerWithTitleMessagePreferredStyle(
  "Title",
  "Message", 
  UIAlertControllerStyle.Alert
);

// Add alert action
const action = UIAlertAction.actionWithTitleStyleHandler(
  "OK",
  UIAlertActionStyle.Default,
  null
);
alert.addAction(action);

Performance Considerations

  • Framework Loading: Only frameworks referenced in code are loaded
  • Memory Usage: iOS declarations are comprehensive and memory-intensive
  • Compilation Time: Large number of frameworks can slow TypeScript compilation
  • Runtime Performance: Native calls have minimal overhead through NativeScript runtime

Install with Tessl CLI

npx tessl i tessl/npm-tns-platform-declarations

docs

android-platform.md

index.md

ios-platform.md

native-interop.md

nativescript-widgets.md

tile.json