Skip to content

Conversation

@txbrown
Copy link
Collaborator

@txbrown txbrown commented Feb 26, 2025

Why

The new architecture has been out for a while and has many benefits that will help the goals of this project. With this in mind I decided to upgrade the codebase to support the new architecture - linked issue #12

How

The upgrade process of RN projects on the native side is always painful and messy. I am sure there is things I could have done better if I had an idea exactly where to go. The process involved reading the docs for []builder-bob](https://callstack.github.io/react-native-builder-bob/faq#how-does-the-library-get-linked-to-the-example-app-in-the-generated-project), new architecture native modules, using a bit of cursor and claude (which to be honest didn't help much).

Here is what I did:

  • create a new native turbo module with new architecture to use as a template / comparison
  • update podspec, package.json, metroconfig and various other files
  • update implementation in Elementary.mm to support new architecture api
  • add a new example project that has new architecture enabled
  • move the "old" example to example_old
  • testing everything works as expected

I would like to also test this all works in an expo project as expo is now the default react-native framework.

To-do

  • Fix android build
  • Fix lint fail
  • Fix test fail

@txbrown txbrown marked this pull request as draft February 26, 2025 01:44
@txbrown txbrown changed the title New architecture native modules Upgrade to new architecture Feb 26, 2025
@txbrown txbrown marked this pull request as ready for review February 26, 2025 16:49
@tamlyn
Copy link
Owner

tamlyn commented Mar 1, 2025

Excellent work!

Did you look at the Expo Modules API? Apparently it has better DX unless you're doing low level C++ stuff, so probably Turbo Modules is a better choice 👍

txbrown and others added 3 commits December 30, 2025 16:16
- Add event emitter support for TurboModules (addListener/removeListeners)
- Fix iOS getSampleRate method signature for old arch bridge compatibility
- Fix Android getSampleRate method signature (remove extra parameter)
- Create old arch package (ElementaryTurboPackage) for Android bridge mode
- Remove pre-generated codegen folders - now generated at consumer build time
- Update iOS header to import spec from Pods headers
- Consolidate iOS example to single project with arch toggle
- Update Podfile with clear architecture toggle comment
- Update C++ standard to c++20 for React Native 0.78 compatibility
- Fix ESLint config to use correct package name (@react-native)

Both architectures tested and working on iOS and Android.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add missing ESLint dependencies (eslint-plugin-ft-flow, hermes-eslint)
- Add metro-react-native-babel-preset for Jest
- Fix Jest modulePathIgnorePatterns to exclude example_old
- Remove codegen from bob targets (runs at consumer build time)
- Update Java version from 11 to 17 for React Native 0.78

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@txbrown
Copy link
Collaborator Author

txbrown commented Dec 30, 2025

@tamlyn sorry I could only come back to this now but I revisited the PR with the help of Claude Code and completed the migration, tested for old and new architecture and it all works.
Please have a look 🙏

- Add example-expo/ with Expo SDK 53 and React Native 0.79
- Configure expo-dev-client for development builds
- Add metro.config.js with resolveRequest to fix React duplicates in monorepo
- Add react-native.config.js for proper codegen integration
- Update root package.json with example-expo script
- Update .gitignore for Expo generated folders

Note: This library requires a development build (`expo run:ios/android`)
and cannot run in Expo Go due to native C++ Elementary Audio dependency.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@txbrown
Copy link
Collaborator Author

txbrown commented Dec 30, 2025

Bonus: added expo example as well

txbrown and others added 3 commits December 30, 2025 22:51
- Add example-expo/ to eslintIgnore
- Add example-expo and example_old to tsconfig.build.json exclude

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The types paths incorrectly included /src/ which doesn't exist in the build output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Owner

@tamlyn tamlyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to pretend I understand it, but it builds and it makes a beep so 👍

@tamlyn tamlyn merged commit 9305335 into main Jan 9, 2026
5 checks passed
@tamlyn tamlyn deleted the new-architecture-native-modules branch January 9, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants