react-native-website icon indicating copy to clipboard operation
react-native-website copied to clipboard

Swift already supports macros

Open ikhvorost opened this issue 8 months ago • 0 comments

Description

iOS Native Modules page contains the following sentence in Exporting Swift section:

Swift doesn't have support for macros, so exposing native modules and their methods to JavaScript inside React Native requires a bit more setup.

https://reactnative.dev/docs/native-modules-ios

But swift already supports macros from the version 5.9 and more over there is ReactBridge swift package (https://github.com/ikhvorost/ReactBridge) that implements all macros for React Native to make pure swift bridges in convenient way. For instance:

@ReactModule(jsName: "Calendar")
class CalendarModule: NSObject, RCTBridgeModule {
  
  @ReactMethod
  @objc func createEvent(title: String, location: String) {
    print("Create event '\(title)' at '\(location)'")
  }
}

So that "Swift doesn't have support for macros" phrase is not correct and should be replaced/removed in the page.

Documentation version

0.74

ikhvorost avatar Jun 06 '24 13:06 ikhvorost