Part 7 · Applications

TurboModule Codegen across Android and iOS

Prerequisites: 03-module-interface-map

Code generation paths

Generated glue is separate from platform business logic; its exact files depend on RN version and configuration. Nodes: Typed spec, Codegen, Android glue, iOS glue.
Generated glue is separate from platform business logic; its exact files depend on RN version and configuration. [S08] [S09]

Mental model verified

React Native Codegen reads a typed spec from the configured source directory. Android output includes Java/Kotlin-facing abstract APIs and JNI/C++ glue; iOS output includes Objective-C++ and C++ interfaces. The native implementation satisfies those generated contracts.

[S08] [S09]

Worked flow synthesis

For readSecureToken(): Promise<string | null>, define nullable result semantics in the spec, run the build/codegen, implement Android Keystore and iOS Keychain behavior, then normalize absent and denied outcomes. This signature is conceptual and not a complete spec.

[S08] [S09]

Engineering decision synthesis

Keep specs narrow, avoid passing unbounded collections, and separate platform service logic from generated glue. Regenerate whenever the spec changes and compile both platforms.

[S08] [S09]

Failure mode and improvement synthesis

A JS type edit without regenerating and rebuilding native artifacts can leave contract drift. Use build checks on Android and iOS plus device integration tests.

[S08] [S09]
Keep this: A TS/Flow spec is the shared contract; Codegen and platform implementations fill different layers.
Check yourself: What does Codegen provide, and what remains yours?

It creates interfaces and glue; you still implement native behavior, errors, permissions and lifecycle.

Sources & further reading

  1. [S08] Using Codegen

    React Native · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Generated Android JNI/Java and iOS Objective-C++/C++ glue.

    Inspect the implementation boundary described by this source.

  2. [S09] Native Modules: Introduction

    React Native · official documentation or maintainer source · accessed 2026-10-09 · current documentation as accessed; examples conceptual

    Supports: Typed TurboModule specification and native implementations.

    Inspect the implementation boundary described by this source.