Trapeze Documentation

website·Indexed 32 days ago

https://trapeze.dev

A native iOS and Android project management utility providing a configuration-driven tool and a Node.js-based API to automate project configuration. It supports native iOS, native Android, Flutter, Capacitor, and React Native projects, and is designed for use in CI/CD and Mobile DevOps automation workflows.

Tokens
10.1K
Snippets
63
Records
72
Agent score
64%

What's inside Trapeze

  1. Overview of Trapeze project management utility

    Trapeze is a utility for managing native iOS and Android projects, supporting traditional native development as well as Ionic/Capacitor, React Native, and Flutter. It provides two primary ways to automate project modifications: a configuration-driven tool that processes YAML files (supporting environment variables) and a Node.js-based Project API for programmatic automation scripts.
  2. Overview of Trapeze project management utility

    Trapeze is a utility designed for managing and modifying native iOS and Android projects, including those built with Ionic/Capacitor, React Native, and Flutter. It offers two primary ways to automate project modifications: a configuration-driven tool that processes YAML files (supporting environment variables) and a Node.js-based Project API for programmatic automation scripts.
  3. Edit project JSON files using JsonFile

    Use the JsonFile class to load, set, and merge values within project JSON files. You can retrieve an existing file or create a new one via getProjectFile.
    // Get or create a JSON file
    const jsonFile = ctx.project.android?.getProjectFile<JsonFile>(
      filename,
      (filename: string) => new JsonFile(filename, ctx.project.vfs, ctx.project),
    );
    
    // Load the file into memory
    await jsonFile.load();
    
    // Set specific values
    jsonFile.set({
      field: 'value'
    });
    
    // Merge values into the existing structure
    jsonFile.merge({
      field: {
        field2: 'value'
      }
    });
  4. Automate iOS project configuration using Trapeze CLI

    Trapeze allows for configuration-driven automation of native iOS projects. To use this experience, define your target platforms and versions in a YAML file and execute it using the @trapezedev/configure package. When targeting a standalone iOS project, operations for other platforms (such as Android) are ignored.
    # config.yaml
    platforms:
      ios:
        targets:
          App:
            version: 16.4
    npm install @trapezedev/configure
    npx trapeze run config.yaml
  5. Modify iOS JSON, XML, and xcconfig files

    Trapeze allows modification of project files relative to the iOS project root:

    • JSON: Use set to override an element or merge to combine values.
    • XML: Supports attrs (update attributes), merge (merge XML tree), inject (inject XML tree), delete (XPath deletion), and deleteAttributes.
    • xcconfig: Use set to define build configuration values.
    platforms:
      ios:
        targets:
          App:
            json:
              - file: google-services.json
                merge:
                  data:
                    field: "MY_FIELD"
            xml:
              - file: file.xml
                target: entries/field
                merge: |
                  <field>
                    <string>Value</string>
                  </field>
            xcconfig:
              - file: App/Config.xcconfig
                set:
                  "PRODUCT_NAME": "$(NAME)"
  6. Automate Capacitor configuration using the Trapeze CLI

    Trapeze allows for configuration-driven automation of Capacitor projects using YAML files. You define platform-specific changes—such as injecting permissions into the AndroidManifest.xml or setting iOS target versions—and execute them via the @trapezedev/configure package.
    # config.yaml
    platforms:
      android:
        manifest:
          - file: AndroidManifest.xml
            target: manifest/application
            inject:
              <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
      ios:
        targets:
          App:
            version: 16.4
    npm install @trapezedev/configure
    npx trapeze run config.yaml
  7. Implement auto-incrementing build numbers in CI/CD

    To automatically increment build numbers for iOS and Android using a CI/CD service (such as Appflow), map the CI-provided build number environment variable (e.g., CI_BUILD_NUMBER) to the buildNumber for iOS and versionCode for Android in your Trapeze configuration.
    vars:
      CI_BUILD_NUMBER:
        default: 1
    
    platforms:
      ios:
        buildNumber: $CI_BUILD_NUMBER
      android:
        versionCode: $CI_BUILD_NUMBER
  8. Automate native plugin configuration on install

    Native plugin authors for frameworks like Capacitor or React Native can distribute a Trapeze YAML file alongside their plugin to automate project configuration. This allows the plugin to modify build settings, plists, or Android manifests automatically when the developer runs the configuration command after installation.
    # Example installation and configuration flow
    npm install my-capacitor-plugin
    npx @trapezedev/configure run node_modules/my-capacitor-plugin/install.yaml
  9. Manage Android resource files

    Trapeze allows you to create, copy, and load Android resource files. The copyToResources method supports passing a local file path or a URL as the source to fetch remote files.
    // Add a resource to a directory (e.g., 'raw') with name and contents
    await project.android?.addResource('raw', 'test.json', `{}`);
    
    // Copy an existing file or fetch from URL to resources
    await project.android?.copyToResources('drawable', 'icon.png', source);
    
    // Load an existing resource
    const data = await project.android?.getResource('raw', 'test.json');
  10. Install and configure @trapezedev/project for custom scripts

    To write custom scripts and code that manage iOS and Android targets in native projects, install the @trapezedev/project package. Additionally, ensure that the dom library is enabled in the lib section of your tsconfig.json under compilerOptions.
    npm install @trapezedev/project
  11. Automate mobile project modifications using the Trapeze Configuration tool

    The Trapeze Configuration tool allows developers to modify mobile projects by defining operations in a YAML configuration file. It leverages the Project API internally and supports environment variables for dynamic configuration. Key capabilities include:

    • Modifying Android Manifest files
    • Performing AST-based modifications to Gradle (Groovy) files
    • Creating Android resource files
    • Configuring iOS project build settings with full target support
    • Updating plist files and entitlements
  12. Automate mobile project modifications using the Trapeze Configuration tool

    The Trapeze Configuration tool allows developers to modify mobile projects using a YAML configuration file. It leverages the Project API internally and supports environment variables for dynamic configuration. Key capabilities include:

    • Modifying Android Manifest files
    • Performing AST-based modifications to Gradle (Groovy) files
    • Creating Android resource files
    • Configuring iOS project builds with full target support
    • Updating plist files and entitlements