How to bridge Swift View in ObjectC for React Native

Viewed 384

I'am new in this Objc and Swift. I need some small example. I dont know what search.

Objective C very complicated for me.

Can anyone give any simple example, how in Objective C import Swift View as react-native module?

//this is swift file
import SwiftUI

struct SwiftUIView: View {
    var body: some View {
        Text("Hello, World!")
    }
}
//i need use RCTView and RCTViewManager somehow in ObjectiveC files

Please give some example how import SwiftUIView or any other View from Swift to ObjectC and add export as RCTView

1 Answers

here's a tutorial how to bridge a native iOS component to react-native https://youtu.be/q5M07Q1JFZw but it's for Alert, if you need to create like a completely custom UI element you will probably need to actually learn swift. It would be easier to help you, if you would describe what are you actually trying to accomplish. Because there are rare scenarios when you actually need to program native UI in a native code.

There's also documentation on importing native modules to react-native https://reactnative.dev/docs/native-modules-intro maybe that can help you.

Related