Titanium SDK

repository·main·Indexed 25 days ago

https://github.com/tidev/titanium-sdk

A cross-platform mobile development platform for building native iOS and Android applications using JavaScript. It features high-performance native execution without WebViews, the Alloy MVC framework, and Hyperloop for direct native API access. The SDK includes tools like the Kroll Annotation Processor for Java and TitaniumKit for iOS-Core.

Tokens
21.3K
Snippets
18
Records
157
Agent score
83%

What's inside titanium-sdk

  1. Overview of TitaniumKit

    main

    TitaniumKit is a standalone framework that contains the Titanium iOS-Core. Its primary goals are to improve compile times by precompiling over 78 headers and to provide Swift module support by utilizing module-based Objective-C sources.

    Key technical transitions in this framework include:

    • Replacing TiJSCore with JSCore.
    • Replacing Kroll-Thread with the Main-Thread.
    • Exposing public headers such as TiProxy, TiViewProxy, and TiModule for testing purposes.
  2. Overview of Titanium SDK

    main
    Titanium SDK is a mature platform for building completely native cross-platform mobile applications using JavaScript. It compiles JavaScript code into efficient native executables for iOS and Android, providing full offline support and native UI controls without using a hybrid WebView approach.
  3. Understand the Android V8 Debugger implementation

    main

    The Titanium Android V8 Debugger uses a hybrid C++, JNI, and Java implementation to replace the removed V8 debug-agent. It functions by:

    1. Opening a port to listen for debugger connections.
    2. Processing messages from the debugger and forwarding them to V8 via V8::Debug::SendCommand and V8::Debug::ProcessDebugMessages().
    3. Processing responses from V8 and forwarding them back to the debugger via a C++ message handler.

    This architecture allows Studio and other debuggers to interact with the V8 engine within the Titanium runtime.

  4. Understand the Common JS SDK file structure

    main
    The Titanium SDK uses core JavaScript files located in the Resources directory that are shared across all supported platforms. These files must be copied to the Titanium app project's build directory during every build process, behaving similarly to how a developer's own Resources files are handled.
  5. Understand the Titanium boot sequence

    main

    The Titanium startup sequence follows this order:

    1. Kernel Loading (ti.kernel.js): Sets up core globals, hooks the Titanium/Ti object, initializes the EventEmitter, and implements the require system via the Module class.
    2. Bootstrap Execution: ti.main.js executes any files ending in .bootstrap.js.
    3. App Entry: ti.main.js loads and executes the developer's app.js file.
  6. Update API documentation

    main

    API documentation (methods, properties, and examples) is maintained in the /apidoc/ directory. After making changes, run the lint command to ensure the documentation remains valid.

    When submitting a Pull Request for documentation, use the prefix docs: in the commit title (e.g., docs: updated textfield examples).

    npm run lint:docs
  7. Understand Android SDK Build-time Prebuilding

    main
    During the Android SDK build process, the ./android/titanium/prebuild.js script is executed. This script processes JavaScript files located in ./android/runtime/common/src/js and converts them into C char* strings. This process 'bakes in' the source code to the binary to prevent disk I/O slowdowns during runtime.
  8. Debug the Kroll Annotation Processor in Eclipse

    main

    To develop or debug the processor, you can run a second instance of Eclipse from your workspace:

    1. Go to Run > Debug Configurations.
    2. Double-click Eclipse application to create a new configuration.
    3. In the Arguments tab, set a large -Xmx value (e.g., -Xmx2048m).
    4. In the Plug-ins tab, select Launch with: all workspace and enabled target plug-ins.
    5. Click Debug. This starts a new Eclipse instance with your workspace's kroll-apt plugin loaded and ready for debugging.
  9. Extend Titanium SDK with Hyperloop

    main
    Hyperloop allows you to extend your Titanium SDK applications by accessing native APIs directly via JavaScript. It enables the implementation of native classes and the incorporation of 3rd-party libraries (such as CocoaPods, local frameworks, or .aar files) for both iOS and Android. This provides direct access to 100% of platform APIs with instant support for new OS releases.
  10. Build and debug the Titanium iOS Core source

    main

    To build and debug the Titanium iOS project for the first time, follow these steps:

    1. Prepare the library: Navigate to titanium_mobile/build and run the installation and build commands to download the titanium_prep library.
    2. Configure app resources: Modify titanium_mobile/iphone/Resources/app.js with your test code. You can also place other resource files in this directory; they will be copied to the .app bundle via the Xcode Script Build Phase.
    3. Run in Xcode: Open titanium_mobile/iphone/iphone/Titanium.xcodeproj in Xcode and press CMD+R to run the application.

    Once running, you can set breakpoints and analyze Kroll-Core or Core Modules directly within Xcode.

    cd titanium_mobile/build
    npm install
    node scons.js cleanbuild ios
  11. Build the Titanium SDK locally

    main

    To build the SDK from source, use the provided npm scripts. The build and package commands default to all target platforms supported by your host OS (e.g., Android & iOS on macOS; Android on Windows). The process compiles, packages, and installs the locally-built SDK, allowing you to test it in your own applications immediately.

    Note: The build command requires the Android SDK path. It will look for the $ANDROID_SDK environment variable if not explicitly provided via the --android-sdk flag.

  12. Install the Kroll Annotation Processor as an Eclipse Plugin

    main

    To use the annotation processor within Eclipse, follow these steps:

    1. Prerequisites: Ensure you have the Eclipse PDE plugins installed.
    2. Build the Plugin: Import the kroll-apt project into your Eclipse workspace. Right-click pde-build.xml and select Run As > Ant Build.
    3. Locate the JAR: After the build completes, find the generated JAR in kroll-apt/bin/plugins/ (named org.appcelerator.kroll.apt_1.0.0.xxx.jar).
    4. Install: Copy this JAR into your Eclipse installation's plugins folder.
    5. Finalize: Restart Eclipse and perform a clean build on your entire workspace.

    Generated bindings will appear in .apt_generated folders under your Titanium projects (you may need to disable the .* resources filter in Package Explorer to see them).