Bridges

Frida Bridges

Version Constraint

Available Bridges

Bridgenpm PackageImport Statement
ObjCfrida-objc-bridgeimport ObjC from "frida-objc-bridge";
Swiftfrida-swift-bridgeimport Swift from "frida-swift-bridge";
Javafrida-java-bridgeimport Java from "frida-java-bridge";

Usage Scenarios

1. REPL / frida-trace — Plain JavaScript (no imports needed)

All three bridges are pre-bundled. Scripts using ObjC, Java, or Swift globals work without any changes.

1// script.js
2console.log(ObjC.available);
1frida -p0 -l script.js

Output:

true
[Local::SystemSession ]->

2. REPL — Automatic TypeScript Compilation

The REPL can compile .ts files automatically. Use frida-create -t agent in an empty directory to scaffold the project; bridges are still bundled in REPL mode.

3. Manual Compilation with frida-compile (TypeScript agents)

Bridges must be explicitly imported in the TypeScript source.

Prerequisites:

Steps:

1// script.ts
2import ObjC from "frida-objc-bridge";
3
4console.log(ObjC.available);
1# In an empty directory:
2frida-create -t agent        # scaffold tsconfig.json, package.json, etc.
3npm install                  # install base deps
4npm install frida-objc-bridge  # install desired bridge(s)
5
6frida-compile script.ts -o _agent.js -S -c   # -S: source maps, -c: compress
7frida -p0 -l _agent.js

frida-compile flags:

FlagMeaning
-o <file>Output file path
-SOmit source maps from output
-cCompress (minify) output with Terser

4. API Usage (Python / Go)

When using Frida bindings programmatically, the workflow is:

  1. Write TypeScript script with explicit bridge imports.
  2. Run frida-create -t agent in the script’s directory to set up tsconfig.json / package.json.
  3. Install bridge package(s) via npm install.
  4. Use the Compiler API to build the bundle, then load it into the target process.

Python

 1import frida
 2
 3def on_diagnostics(diag):
 4    print("diag", diag)
 5
 6def on_message(message, data):
 7    print(message)
 8
 9compiler = frida.Compiler()
10compiler.on("diagnostics", on_diagnostics)
11# script.ts is located in /tmp; set project_root so tsconfig.json is resolved
12bundle = compiler.build("script.ts", project_root="/tmp")
13
14session = frida.attach(0)      # 0 = attach to system session
15
16script = session.create_script(bundle)
17script.on("message", on_message)
18script.load()

Key API:

CallDescription
frida.Compiler()Create a compiler instance
compiler.on("diagnostics", fn)Subscribe to compiler diagnostic events
compiler.build(path, project_root=...)Compile TypeScript, returns JS bundle string
frida.attach(pid)Attach to process by PID (0 = system session)
session.create_script(source)Create script from source string
script.on("message", fn)Subscribe to send() messages from script
script.load()Inject and execute the script

Go

 1package main
 2
 3import (
 4    "bufio"
 5    "fmt"
 6    "github.com/frida/frida-go/frida"
 7    "os"
 8)
 9
10func main() {
11    comp := frida.NewCompiler()
12    comp.On("diagnostics", func(diag string) {
13        fmt.Printf("Diagnostics: %s\n", diag)
14    })
15
16    bopts := frida.NewCompilerOptions()
17    bopts.SetProjectRoot("/tmp")                         // directory containing tsconfig.json
18    bopts.SetSourceMaps(frida.SourceMapsOmitted)         // omit source maps
19    bopts.SetJSCompression(frida.JSCompressionTerser)    // minify with Terser
20
21    bundle, err := comp.Build("script.ts", bopts)
22    if err != nil {
23        panic(err)
24    }
25
26    session, err := frida.Attach(0)
27    if err != nil {
28        panic(err)
29    }
30
31    script, err := session.CreateScript(bundle)
32    if err != nil {
33        panic(err)
34    }
35
36    script.On("message", func(message string, data []byte) {
37        fmt.Printf("%s\n", message)
38    })
39
40    script.Load()
41
42    r := bufio.NewReader(os.Stdin)
43    r.ReadLine()   // keep process alive
44}

Key Go API:

CallDescription
frida.NewCompiler()Create compiler instance
frida.NewCompilerOptions()Create build options struct
bopts.SetProjectRoot(path)Directory containing tsconfig.json / package.json
bopts.SetSourceMaps(frida.SourceMapsOmitted)Omit source maps from bundle
bopts.SetJSCompression(frida.JSCompressionTerser)Minify with Terser
comp.Build(file, opts)Compile TypeScript to JS bundle
frida.Attach(pid)Attach to process (0 = system session)
session.CreateScript(bundle)Create script from bundle string
script.Load()Inject and execute the script

Summary Decision Table

ContextBridge import required?Compilation needed?
REPL plain JS (frida -l script.js)NoNo
REPL with .ts fileNo (REPL bundles bridges)Auto (REPL handles it)
frida-traceNoNo
frida-compile + TypeScript agentYesYes (frida-compile)
Python/Go API with TypeScript agentYesYes (compiler.build(...))