---
title: "Writing Your First TurboModule in Swift"
description: "Learn how to build a fully working TurboModule in Swift, integrate it with Codegen, and bridge it through Objective‑C inside an Expo app."
url: https://www.callstack.com/tutorials/writing-your-first-turbomodule-in-swift
updated: 2026-10-24T08:39:46.438Z
---

# Writing Your First TurboModule in Swift

Learn how to build a fully working TurboModule in Swift, integrate it with Codegen, and bridge it through Objective‑C inside an Expo app.

_Video tutorial · 2025-12-22 · Length: 18:20 · Category: React Native_

Teachers: Oskar Kwaśniewski (Software Developer @ Callstack)

[Watch on YouTube](https://www.youtube.com/watch?v=qA7Idf_kUeA)

React Native’s New Architecture makes TurboModules the default path for extending functionality. In this tutorial, Oskar walks through the full workflow: bootstrapping the project, exploring Codegen output, writing the Swift implementation, adding an Objective‑C bridge, and verifying the module inside a real app.

## Bootstrapping the library with React Native Builder Bob

Oskar starts by creating an Expo project and using [Builder Bob](https://oss.callstack.com/react-native-builder-bob/) to scaffold a TurboModule library. This generates platform folders, a starter TypeScript spec, and default native code. Highlight the moment where he swaps the default `multiply` method for the Local Storage API (`setItem`, `getItem`, `removeItem`, `clear`).

## Understanding the TypeScript spec and Codegen contract

The TypeScript spec defines the contract between JS and native. Codegen reads this file during `pod install` to produce Objective‑C/C++ headers that ensure type‑safe communication. Oskar shows where these headers live in Xcode and how they directly mirror the TypeScript definitions.

## Navigating generated code in Xcode

Once `expo prebuild` and `pod install` run, the iOS folder appears with generated native targets. Oskar demonstrates how to locate the TurboModule inside the Pods hierarchy and why Xcode must build once before symbols resolve.

## Implementing the business logic in Swift

The core logic lives in Swift: a `NativeLocalStorage` class backed by `UserDefaults` with a custom suite name. Oskar walks through the implementation of each method, including potential pitfalls (Swift types unsupported by Objective‑C).

## Bridging Swift to Objective‑C

TurboModules require an Objective‑C layer. Oskar shows how to import the generated Swift header, create an instance variable, initialize it in `init`, and forward calls from Objective‑C into Swift. He discusses why attributes like `@objcMembers` are required for visibility.

## Testing the TurboModule in an Expo application

The episode concludes with adding simple UI buttons that call the TurboModule from JavaScript. Oskar demonstrates setting a value, retrieving it, and verifying persistence via breakpoints in Xcode.

## Resources

- Oskar Kwaśniewski on [X](https://x.com/o_kwasniewski/) and [GitHub](https://github.com/okwasniewski)
- [Other episodes in this series](https://www.youtube.com/playlist?list=PLZ3MwD-soTTE9yIH2ziaxBO6ytManw5Qc)
- Tools & libraries:
  - [React Native Builder Bob](https://oss.callstack.com/react-native-builder-bob/)
  - [Expo](https://expo.dev/) (for prebuild + testing)
  - [TurboModules](https://reactnative.dev/docs/turbo-native-modules-introduction) (New Architecture)
  - [Codegen](https://codegen.com/)

**TurboModules feel powerful but risky?** We help teams use them with confidence in real production apps. [Let’s chat](/contact)
