Using Titanium Hyperloop to Call Native APIs from JavaScript
Enable Hyperloop in tiapp.xml to invoke iOS and Android native classes from JavaScript, with build-time checks and trade-offs to consider.
27 Mar 2026, 08:24 UTC

The problem: a native API your Titanium app can't reach
You are building a Titanium app and need a platform capability that the standard Titanium APIs do not expose - perhaps a specific camera setting, a Bluetooth LE peripheral flow, or a third-party vendor SDK. The traditional path is to write a native module in Objective-C or Swift for iOS, or Java or Kotlin for Android, then bridge it back to JavaScript. That works, but it means maintaining parallel codebases and context-switching between languages for a single feature.
Hyperloop is a Titanium SDK feature that lets you instantiate and call native platform classes directly from JavaScript. Instead of writing a wrapper module, the SDK generates native glue code at build time so your JavaScript can talk to UIKit on iOS or Android framework classes as if they were ordinary objects.
What changes when you enable Hyperloop
Hyperloop is not a runtime interpreter. When you build the app, the Titanium SDK inspects the native frameworks you reference, generates metadata and C/Objective-C or Java/Kotlin glue, and compiles that glue into the application binary. Your JavaScript calls are compiled into native invocations rather than being looked up dynamically while the app runs.
Because native code is compiled into the app, build times can increase and the binary can grow. Native crashes and memory handling are also less forgiving than standard Titanium APIs. A bad reference or an object that is garbage-collected on the JavaScript side while still in use natively can crash the application.
Enable Hyperloop in tiapp.xml
Open tiapp.xml in your project root and add or set the Hyperloop flag inside the ti:app element:
<ti:app>
...
<hyperloop>true</hyperloop>
...
</ti:app>
Run the build from your project directory:
cd <your-project-directory>
ti build --platform ios --device-id <simulator-udid>
Required permissions: normal user access to the project folder and the Titanium CLI build tools. No special root access is needed, but you must have the corresponding platform SDK (Xcode for iOS, Android SDK for Android) installed.
Expected check: after a successful build, inspect the generated build directory for native glue files related to Hyperloop. Their presence confirms the SDK compiled native bindings rather than leaving the calls to resolve at runtime.
Worked example: show an Android toast from JavaScript
A minimal Android example might look like this in your Alloy controller or classic Titanium file:
var Toast = require('android/widget/Toast');
var context = Ti.Android.currentActivity;
var toast = Toast.makeText(context, 'Hello from Hyperloop', Toast.LENGTH_SHORT);
toast.show();
On iOS, the equivalent pattern for creating a color might be:
var UIColor = require('UIColor');
var color = UIColor.colorWithRed_green_blue_alpha(1.0, 0.0, 0.0, 1.0);
These snippets illustrate the call pattern. Verify the exact class names and method signatures against your target platform SDK and Titanium release, because they vary by OS version.
Trade-offs and limitations
- Build time and binary size: Native metadata and glue code are compiled into every build that uses Hyperloop, which can slow CI and increase app download size.
- Platform dependency: Support depends on the Titanium SDK version and the underlying iOS or Android SDK. A new OS release may require Hyperloop or app-code updates.
- Debugging: Native crashes and memory-management mistakes are harder to trace than JavaScript exceptions. Pay attention to object lifetimes, especially when passing objects between JavaScript and native code.
Use Hyperloop when the standard Titanium API does not cover the native capability you need and you do not want to maintain a separate native module. If a Titanium API or community module already covers the feature, prefer that instead.
Check the result and roll back if needed
- Build the app with Hyperloop enabled and confirm it installs on an emulator or device.
- Run the native call path and watch for crashes or missing-symbol errors.
- Open the platform-specific build output and look for generated Hyperloop glue files to confirm compilation happened.
If Hyperloop causes build failures or crashes you cannot resolve, remove <hyperloop>true</hyperloop> from tiapp.xml, clean the project build directory, and rebuild. That returns the project to standard Titanium API behavior.
Bottom line
Hyperloop lets you keep more integration code in JavaScript by calling native iOS and Android classes directly. Treat it as an escape hatch for APIs outside Titanium's standard namespaces, verify it against your target SDK versions, and keep the rollback step handy if build times or stability become a problem.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.