Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export swift module with turbo modules to react-native #48501

Closed
gurkan-baykan opened this issue Jan 6, 2025 · 3 comments
Closed

export swift module with turbo modules to react-native #48501

gurkan-baykan opened this issue Jan 6, 2025 · 3 comments
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@gurkan-baykan
Copy link

Description

Is it possible to call my swift modules with turbo modules without a bridge by react-native, codegen can generate the c++ code needed by turbo modules for swift modules, if it possible , can you show example

Steps to reproduce

no

React Native Version

0.76.5

Affected Platforms

Runtime - iOS

Areas

TurboModule - The New Native Module System

Output of npx react-native info

System:
  OS: macOS 14.2
  CPU: (12) arm64 Apple M2 Pro
  Memory: 1.43 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.0.0
    path: ~/.nvm/versions/node/v22.0.0/bin/node
  Yarn:
    version: 3.6.4
    path: /usr/local/bin/yarn
  npm:
    version: 10.5.1
    path: ~/.nvm/versions/node/v22.0.0/bin/npm
  Watchman:
    version: 2024.08.12.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    Android NDK: 22.1.7171670
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 20.0.2
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: /Users/gurkan/.rvm/rubies/ruby-3.2.2/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: 15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

no error

Reproducer

https://github.com/react-native-community/reproducer-react-native.git

Screenshots and Videos

No response

@gurkan-baykan gurkan-baykan added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jan 6, 2025
@react-native-bot react-native-bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jan 6, 2025
@react-native-bot
Copy link
Collaborator

Warning

Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

@gurkan-baykan gurkan-baykan changed the title export swift module with turbo modules export swift module with turbo modules to react-native Jan 6, 2025
@cipolleschi
Copy link
Contributor

Hi @gurkan-baykan, thanks for the question.
It is currently not possible to do that. Codegen generates an objective-C++ interface for the module that contains some pure C++ code. Currently, it is not possible for Swift to directly import a header file that contains pure C++ code.

If you have a module in Swift, you need to wrap it inside an Objective-C++ wrapper that implements the Objective-C++ interface generate by codegen and forwards calls to the Swift implementation.

@gurkan-baykan
Copy link
Author

gurkan-baykan commented Jan 6, 2025

so I need to create a bridge structure to call a swift module, am I correct?

Hi @gurkan-baykan, thanks for the question. It is currently not possible to do that. Codegen generates an objective-C++ interface for the module that contains some pure C++ code. Currently, it is not possible for Swift to directly import a header file that contains pure C++ code.

If you have a module in Swift, you need to wrap it inside an Objective-C++ wrapper that implements the Objective-C++ interface generate by codegen and forwards calls to the Swift implementation.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

3 participants