How to use view created in swift inside an objective-c++ file? #57
Replies: 3 comments
-
Disclaimer: I'm not a Swift expert. I believe what you're trying to achieve is not possible. In order to use Swift, you'll have to enable |
Beta Was this translation helpful? Give feedback.
-
Hey @cortinico Check this repo I have used |
Beta Was this translation helpful? Give feedback.
-
@cortinico Also check this |
Beta Was this translation helpful? Give feedback.
-
I am trying to use
react-native's new architecture
and I have enabledfabric
for the same. I am able to use a view created inobjective-c++
inside mytypescript
code. But I want to use a view created inswift
withUIKit
in myobjective-c++
fileThe documentation on react-native's website is still for the old architecture of using bridge so it does not directly apply in my case. There are pretty significant changes in the new architecture.
Below is the working code for objective-c++ file
Now to use a
view
which is created inswift
inside myobjective-c++
file, I use the following approachCreated a swift file called
RNThubView
. Following is the code for the sameAnd I updated my
objective-c++
file code to the followingRest of the code remains mostly the same in
objective-c++
file.Now when I run via cli, the app crashes with no logs on cli. When I run via
Xcode
, I get following logs with a white screen on the simulatorFull source is here https://github.com/PritishSawant/ReactNativeFabricSwiftTry
Also how to pass
props
fromobjective-c++
toswift
. In my example it is acolor
prop which once set from react-native's side should use the value in myswift
file.Beta Was this translation helpful? Give feedback.
All reactions