Custom React Native Components in Swift

If you're struggling in getting your Swift code to work with React Native, then rejoice!
Kevin deLeon has packed up a great tutorial for custom React Native Components in Swift.

The core of React Native contains a TON of what you need to build a pretty awesome app. However, from time to time, we’ll likely need to write our own custom component, re-use some Swift code we’ve used in the past, or take advantage of some platform specific API that isn’t available in the core. The React Native team has done a fantastic job of making this possible via the RCTBridgeModule (or React Native bridge). When React Native was first released, this could only be accomplished using Objective-C. I admit, I’m not a huge fan of Objective-C. I know it’s a great language, but coming from JavaScript, PHP, Ruby, etc..., the syntax is just so foreign feeling to me. I know I’d get it eventually, but Swift just ‘feels’ so much better. Thankfully, the ability to export custom components in Swift has arrived. I did quite a bit of searching for examples, but really only found the documentation available on the React Native website, and a pretty great tutorial by Jay Garcia on building custom components in Objective-C.

Armed with the manual and Jay’s tutorial, I decided to implement Jay’s MCFileWriterUtil in Swift and export to React Native!

Blog post

Accompanying code on GitHub.