App Development

A Swift Developer’s React Native Experience

I began this Swift blog almost three years ago when I was a Swift-only mobile developer looking to become a full time iOS developer. I haven’t blogged for a long time here. Let’s just say…things are different now. 😁

I now write 99% JavaScript in React Native. 🤭

Here’s how I got there. And why I ❤️ it.

People Are Talking About React Native

React Native over the past month has had quite the rollercoaster ride. It started when this post appeared on Twitter:

It was quickly deemed to be an incorrect statement. Sophie Alpert, an Engineering Manager on React at Facebook, wrote a post about how React Native has a bright future and is being reworked under the hood to be even better. A few days later, another dip as Airbnb announced that it was going to stop using React Native. Ash Furrow, an engineer at Artsy working in React Native who previously worked in native iOS, wrote about The Case for React Native and Airbnb and React Native Expectations, which offered some great pro-React Native perspectives.

React Native at Skip

I’ve been working at SkipTheDishes in Winnipeg since March 2016 on the iOS team. When I started at Skip, the iOS and Android teams were programming purely in native with Swift and Java respectively. Late last summer in 2017, it was decided by the Senior mobile devs that we wanted to see how rewriting the app that our food couriers use in React Native would work. So the iOS and Android teams merged and together we all began learning JavaScript and React Native.

I’ll be honest–initially I was discouraged by the decision, and I struggled a lot with comprehending JavaScript and React for the first month or two so. It’s so completely different than creating apps natively. Swift and JS are pretty polar opposites, but JavaScript combined with a type system like flow or TypeScript takes much of the pain away from working with plain JavaScript. Another struggle for me was that I’m a highly visual person so doing UI layout in JSX markup using Flexbox rather than Xcode’s Interface Builder was really hard to adapt to at first (now I love it, though, and I can build pretty much anything! 😄).

Overall, I’ve really enjoyed learning React Native and everything that comes along with it. I’m glad I didn’t give up on it. I’ve been working exclusively with React Native at Skip for about a year now, and I actually prefer it to working natively on iOS 😱.

React Nativifying BB Links

My personal iOS app, BB Links, was written in Swift and launched while I was interviewing to work at SkipTheDishes back at the beginning of 2016. It’s now on version 5 after many, many improvements and redesigns. What I’ve learned at Skip has improved my software development skills in every way possible. My iOS app now has over 90K downloads and 23K monthly active users—I’m proud of how much it helps Beachbody Coaches run their home businesses!

Beachbody Coaches with Android devices have continuously asked me for an Android version of BB Links. I had only taught myself how to write apps for iOS in Swift, so writing an Android app in Java would be a completely different beast—and I wasn’t particularly keen on learning Android development from scratch in my evenings/weekends. So my answer to them was always “Sorry, but there won’t be an Android version of BB Links since I only know how to make iOS apps.”

At Skip, as I became more and more experienced with and confident using JS and React Native, I began pondering whether I had the ability to make a version of BB Links in React Native; It would allow me to make an Android version of BB Links without the need to learn native Android development. I knew it would be a challenge, but figured I’d give it a shot.

I made a quick MVP of my app in React Native and kept pushing myself piece by piece until I was sure building the full blown app was definitely something I was capable of. I bought a used Android device on Ebay, and went to work.

It wasn’t easy—there were many frustrations along the way—but the finished app has a 100% custom UI that matches the native iOS app, and has 95% of the same functionality. I decided to make the React Native version Android only, keeping the iOS app native in Swift as a way for me to have a project in Swift that I can continue to work on since my day job at Skip is all React Native now.

BB Links iOS vs Android React Native

BB Links on iOS (left) written in Swift in native iOS code compared to BB Links on Android (right) written in JavaScript in React Native. The Android app uses elevation with a more carded/paper look akin to Google’s Material Design.

This past week I published the completed Android app on Google Play. I’m proud of how it turned out—it functions great, looks like the iOS app, with some paper qualities that fit more on Android, and I’ve become an even better React Native developer while creating it. Having to do every single part of an app from start to finish makes you learn so much more than when you only work on pieces of an app.

Frameworks Used in BB Links React Native

The app uses some great React/React Native frameworks:

5 Things I Love About React Native

Here’s a list of five things I love about React Native overall:

  1. State management with Redux combined with Re-select is brilliant. Redux ensures unidirectional logic flow, which reduces bugs and makes for highly predictable reactive components. Combined with Reselect allows for memoization of logic to eliminate wasteful recalculations, improving performance.
  2. Reloading UI takes seconds with things like Hot Reloading. Change a colour, margin, text, etc. and you can see it updated in the simulator right away. This saves so. much. time.
  3. Creating React Components with Flexbox makes it so easy to make pretty much anything. It takes a while to learn, but once you do, it’s very flexible and intuitive.
  4. Once you learn React Native, you can create websites in React, the original version for web, with needing to learn only a handful of new things. At Skip, I’m now doing some web development in React as well, working on our Courier web portal redesign.
  5. Testing with Jest is great. Once you figure out the mocking part, testing UI, global state, and selector logic is quite easy. Using Enzyme (created by Airbnb), you can take snapshots of your UI with different properties applied to test how it renders and ensure it doesn’t unexpectedly change.

5 Things I Don’t Love About React Native

React Native isn’t perfect. Here are some things that need improvement.

  1. Getting an app started from scratch is complicated. There are things like Create React Native App which help, but if you need any frameworks with native code, which most apps will likely need, setup is much less straightforward.
  2. Needing to write native code that’s bridged to JS is a challenge. As Sophie wrote about in the article linked at the start of this post, Facebook is working to make this easier. Right now, it’s not fun. Also, the fact that a Swift iOS developer would now need to still learn some Android with Java to write the Android native code for the feature complicates things greatly. Now you need to know three languages to do a feature on your own.
  3. Plain JavaScript is too scary for the Swift/Java dev. Once you work with a type-safe language, moving to one that has zero type safety feel like you’re walking on thin ice. Using Flow and TypeScript help greatly with that. Flow is added via a framework, while TypeScript is a subscript of JavaScript and requires a bit more work to use (but greatly worth it in my opinion). The fact that there are two type systems used in the React ecosystem creates some fragmentation and incomplete typings that I wish was better.
  4. There is no official navigation library for React Native. You need to choose one of the externally maintained frameworks; either React Navigation, which is 100% JavaScript and thus very flexible yet has some performance issues, or React Native Navigation, which uses platform native navigation and thus has better performance, but weaker flexibility.
  5. React Native performance on Android isn’t as smooth as iOS. This page in the documentation has some info on how to improve performance of React Native overall.

What’s Next?

At Skip I now get to mentor new React/React Native developers who go through our Incubator program, as well as those on the Courier team who are learning the ropes. I love helping people learn about React and React Native, and I always learn something myself at the same time. Seeing them create things and be proud when they get it is awesome! ❤️

I’m also excited to work next on adding the remaining 5% functionality that I held back on for the Android app’s initial launch. It’s the more advanced stuff like in-app purchases for removing ads & tipping, and adding all 100+ themes like the iOS app has (I finished this, but it requires tipping to be released).

Overall, learning React Native has been great. React is an incredible skill I’ve been fortunate to have been able to learn in-depth working at Skip (we’re hiring Senior React developers, by the way). I know it has a bright future. And creating a React Native version of my personal application has been a fantastic experience filled with excitement, amazement that I could do it, and of course—frustration; but you can’t grow if you don’t fail and struggle. Taking the easy way out never has been much of an option for me in life, anyway.

Standard
Best Practices, Resources

🐤 Swift 3 Function [Re-]Naming Resource

With Swift 3 officially released, it may be time to start migrating Swift 2.2/2.3 Code to Swift 3. But as this article points out, there are some major changes in terms of best practices for naming functions in Swift 3. 

Definitely give this one a read; I really like how it takes you step by step to improve the function names using examples. 👌

http://inaka.net/blog/2016/09/16/function-naming-in-swift-3/

Standard
Best Practices, Resources

Learning TDD

I’m currently intrigued with how TDD (Test Driven Development) can help me become a better developer. The problem is…you see TDD mentioned a lot on the Internet, but it’s hard to come across good explanations of HOW to actually DO Test Driven Development.

I first became interested in learning TDD because I read in the book I’m reading now called The Clean Coder: A Code of Conduct for Professional Programmers that TDD isn’t optional–it’s required if you want to be seen as a professional coder, which of course I want to be! 🙂 In the book, Robert Martin discusses using Katas for TDD, so I thought I’d give it a try.

What is a TDD Kata?

TDD Kata was first introduced in the book The Pragmatic Programmer: From Journeyman to Master (which I have yet to read…it’s next on my list). Essentially, it’s taking a set of predefined programming steps that take you through a programming problem from start to finish, using proper TDD techniques right from the start. Its goal is to teach via muscle memory. This blog post describes it well.

My First TDD Kata

Today I did The Bowling Game Kata (linked below) from start to finish. I plan to do it daily for 15 minutes (as suggested by Marlena below). I definitely see the benefit now.

My first reaction as I went through each step of the kata was to check to make sure my logic was correct…but then I realized that that’s why the test was written before writing the logic–it was already verified to be correct since the test passed. Still–I found it hard not to try to run through the logic to make sure (which is muscle memory from non-TDD habits–exactly what I’m trying to break :)).

Fun!

TDD/TDD Kata Resources

Here’s what else I’ve come across that I’ve found helpful thus far in terms of TDD:

Marlena Compton’s Learn TDD with Katas

Marlena describes a 15-minute-per-day technique of learning TDD using Katas. The point is to follow the Kata step by step, which goes through the proper method to do TDD, bit by bit, day by day, to practice and make the act of writing tests before logic the most natural and comfortable way of coding for you.

Jon Reid’s Xcode TDD Kata: Practice with the Bowling Game

Jon adapted this Java TDD Kata so it is in both Objective-C and Swift. It describes what TDD Kata is, and how to do it.

Martin Fowler’s Mocks Aren’t Stubs

Martin describes the different ways in which you can create your app’s objects needed to test your app. It’s an oldie, but I found it to be very good at describing different techniques for actually building your tests for TDD.


I’ll update this post as I learn and find more resources!

-Justin

Standard
Resources

My Favourite iOS Development Podcasts

Podcasts are an essential part of my learning workflow. I’ve only discovered the power of podcasts in the past couple of years, and I find them super useful for learning new things and keeping up with the latest news and tips and tricks!

I subscribe to many different podcasts, but right now I’ve been mainly sticking to iOS Development-themed shows to help accelerate my learning rate. I’m confident in saying that it’s accomplishing that goal!

Typically I’ll digest these podcasts in the shower using my Bluetooth speaker, in my car to and from work, and sometimes during work.

Here are my top picks (in no particular order)!

Top Picks

More Than Just Code

Website: http://mtjc.fm

Description: Each week, Aaron Vegh, Jaime Lopez, Mark Rubin (sometimes Greg Heo), and Tim Mitra discuss iOS and Mac development, including current issues, what developers are talking about, what their apps are about, what they are using to create their apps and what advice they have for other developers (or those looking to become one). It also features news, notes and tech tips for developers.

Why I Like It: It’s got a Canadian perspective, eh! 🇨🇦 A minimum of 50% Canadian hosts—sometimes 100%! 👌 The crew has great chemistry and each episode is always full of entertaining shenanigans. The show talks about real-world problems developers face and how they deal with them. Also I always love the picks.

Under The Radar

Website: https://www.relay.fm/radar

Description: From development and design to marketing and support, Under the Radar is all about independent app development. It’s never longer than 30 minutes. Hosted by Marco Arment and David Smith.

Why I like It: Marco and David are influential and successful indie developers who know their stuff. Each episode is focused on a single focused topic that’s to the point and under 30 minutes. Start from the beginning as it’s rather new.

iOhYes

Website: http://5by5.tv/iohyes

Description: A podcast by iOS developers for iOS developers, delivering news, tips, and rants for professional iOS/Mac developers, with something for enterprise and indie developers alike.
Hosted by Darryl Thomas, John Sextro, and Nolan O’Brien.

Why I Like It: These guys always have very focused, intelligent, technical discussions that are very detailed—we’re talking calling out and describing actual APIs. I always come away learning something new and/or understand better! Nolan is excellent at explaining technical topics.

Release Notes

Website: http://releasenotes.tv

Description: Release Notes is a weekly podcast about the business of Mac and iOS indie software development. It discusses inspiration, design, trends, and tools — everything but the code. The show is hosted by Charles Perry and Joe Cieplinski. Each week it covers topics for the new or curious independent developer looking to make his or her way in the iOS and Mac ecosystem. Tips and tricks, success stories as well as failures.

Why I Like It: It covers a wide range of topics with really great perspectives. I’m always learning something new about the business side of software. Great hosts!

Core Intuition

Website: http://www.coreint.org

Description: A podcast about indie software development for the Mac, iOS and other Apple technologies. Hosted by Daniel Jalkut and Manton Reese.

Why I Like It: Daniel and Manton are down to earth hosts who have great chemistry and aren’t afraid to say it like it is. It’s always a great way to keep up on the latest trends and often discussion of the softer parts of being a developer. Lots of tomfoolery.

Honourable Mentions

The RayWenderlich.com Podcast

Website: http://www.raywenderlich.com/rwpodcast

Why It Missed The Top: It recently moved to two 20 minute topics per episode…and while the content and focus is great, I just find it a bit too rushed now. Still recommended!

Concepts In Code

Website: http://podcast.conceptsincode.com/size/2

Why It Missed The Top: It’s a great podcast that discussed really good best practices, but sometimes it goes a bit on a tangent and it’s also a bit difficult to just listen to since it relies on the github project discussed. Great discussion nonetheless!

Are there any I’m missing that you find are key? If so tweet them at me @jstheoriginal or leave a comment below. 🙌

P.S. I use Marco’s Overcast podcast app…if you do as well make sure to hit the Recommend button on these podcasts!

Standard
Best Practices

The Style Guide for Prolific Interactive’s Swift Codebase

https://github.com/prolificinteractive/swift-style-guide

As my blog makes clear, I’m all about clean code and following best practices.1 Example: I always need to delete extra spaces between closing braces in my code. It must look perfect. 🙈

Prolific Interactive created a github repository that outlines their style guide for all of its Swift codebase. Great best practices. I align with most of what’s included, so take a look!


  1. I follow Ray Wenderlich’s Swift Style Guide found here
Standard
Resources

Xcode: Navigating Through Your Project

Xcode can be a bit daunting at first when you’re starting out as an iOS developer. It’s a very complex and capable program, which means it can be hard to find what you’re looking for.

Thomas has some good tips for Xcode, including using landmarks (TODO:, MARK:, FIXME:), search, groups and callers—which all make it much easier to find what you’re looking for or what you need to come back to later.

Check it out!

Link