Trapeze Documentation
website·Indexed 32 days ago
https://trapeze.devA 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.
What's inside Trapeze
- 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.
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.Edit project JSON files using JsonFile
Use theJsonFileclass to load, set, and merge values within project JSON files. You can retrieve an existing file or create a new one viagetProjectFile.// 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' } });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/configurepackage. When targeting a standalone iOS project, operations for other platforms (such as Android) are ignored.# config.yaml platforms: ios: targets: App: version: 16.4npm install @trapezedev/configure npx trapeze run config.yamlModify iOS JSON, XML, and xcconfig files
Trapeze allows modification of project files relative to the iOS project root:
- JSON: Use
setto override an element ormergeto combine values. - XML: Supports
attrs(update attributes),merge(merge XML tree),inject(inject XML tree),delete(XPath deletion), anddeleteAttributes. - xcconfig: Use
setto 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)"- JSON: Use
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/configurepackage.# 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.4npm install @trapezedev/configure npx trapeze run config.yamlImplement 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 thebuildNumberfor iOS andversionCodefor Android in your Trapeze configuration.vars: CI_BUILD_NUMBER: default: 1 platforms: ios: buildNumber: $CI_BUILD_NUMBER android: versionCode: $CI_BUILD_NUMBERAutomate 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.yamlManage Android resource files
Trapeze allows you to create, copy, and load Android resource files. ThecopyToResourcesmethod 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');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/projectpackage. Additionally, ensure that thedomlibrary is enabled in thelibsection of yourtsconfig.jsonundercompilerOptions.npm install @trapezedev/projectAutomate 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
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