facebook / react-native-website

The React Native website and docs
https://reactnative.dev
MIT License
1.91k stars 4.34k forks source link

Swift already supports macros #4138

Open ikhvorost opened 4 weeks ago

ikhvorost commented 4 weeks ago

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