Fixing an error when unwrapping an Optional value crash

Photo by Hannah Joshua on Unsplash

When I was starting developing iOS app in Xcode I constantly ran into this error:

Fatal error: unexpectedly found nil while unwrapping an Optional value

This fatal error was really frustrating and blocked my progress learning Swift.

What Is an Optional and Why Does It Cause My App to Crash?

Simply put, an Optional is a way to use nil values in Swift. nil is nothing, and is different from zero (0) or an empty string (""). This can be explained by the image below.


Using Grand Central Dispatch (GCD) to speed up your app

Photo by Oleg Magni on Unsplash

Threading in iOS can be difficult to understand if you’re coming from other platforms, or if you are a beginner at Swift. Here’s a few tips to get you off on the right foot with threading, by using GCD.

First a precursor, threading is all about managing how work is prioritized in your app. Making your code execute faster is great, but what matters more is how fast the user perceives your app to be.

Your goal as a developer is to prioritize anything that the user can see and interact with. It makes your app feel faster and snappier…


SceneKit is one of my favorite Apple iOS Frameworks. It allows for developers at all different levels to create 3D scenes and animations. When things go wrong though it can be difficult to find the cause. Here are a few tips to diagnose issues.

1. Scenekit graph Debugger

If you only take away one thing from this post let it be this. The biggest issues with scenekit is usually managing the hierarchy of SCNNode objects. Sometimes node are out of place or not showing up in the scene at all. …


Xcode is an amazing tool to create iOS apps, but sometimes it can be a little clunky and slow down your workflow. Here are a couple of tips to improve your workflow, hopefully saving you time and headaches.

1. Track Build times

Build times are the worst thing about Xcode. To improve anything you first need some way of measuring it. To measure build times in Xcode in seconds open terminal and type this command:

defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES

Afterwards you might need to restart Xcode to see the change. …


Stay sane and remove unused code in Xcode easily with this ruby script. Add the script in a ruby file in your projects main folder called unused.rb. You can either run the code in the terminal with:

$ ruby unused.rb

The terminal will spit out a list of unused functions and variables found in your project.


An image I used to classify my cat Cleo

This year at WWDC, Apple announced new updates to the CoreML and announced new support for creating CoreML on a Mac. In the Vision for CoreML WWDC video the Apple Engineers demonstrated this. They took images of a computer part and fed those images into Turi Create, and out popped a CoreML model that could correctly identify what part it was.

Here’s a quick guide to make your own, even if you don’t know how to code!

All told it shouldn’t take you more than 30 minutes to create a simple model like this.

You’ll need a Mac running High…

Gabriel Lewis

iOS Engineer | http://gabriellewis.me

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store