Update: August 2023

The book project is on hold for now for two reasons. The first reason is a lack of interest. The second reason is I haven’t been able to create a path that people can follow to fix the build and runtime errors in their Swift code.

A fundamental problem I ran into is a book on fixing Swift code is a book for people new to app development. These people don’t know Swift Dev Journal exists, let alone know that I was writing a book to help them. I wrote four articles that explained and fixed a common Swift error and put a call to action to visit this site at the end of the article. People read the articles and didn’t visit this page.

I may resume this book if I can find a path for people to follow to fix the errors in their code and can find a way for people new to iOS development to know about this site and this book.

Swift Errors are Tough to Fix and have Confusing Messages

You want to make an iOS app in Swift. You start going through a course (or book or tutorial) on iOS development, such as Hacking with Swift’s 100 Days of SwiftUI. You follow the instructions exactly, writing the same code and doing the same things the author does.

You build the project and problems arise. The build fails and you get a bunch of error messages that make no sense, like the following:

  • Command CompileSwiftSources failed with a nonzero exit code.
  • The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions.
  • Error: Cannot convert value of type URL? to expected argument type URL
  • Expected , separator
  • Generic Parameter T could not be inferred.

If you’re lucky, the project builds, but the app crashes with gibberish messages like the following:

  • Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
  • Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  • Unrecognized selector sent to instance
  • Thread 1: EXC_BAD_ACCESS (code=2, address=0x102044190)

How are you supposed to figure out what the errors even mean, let alone fix them? There’s no mention of error messages like this in the course material.

You can ask questions on Stack Overflow, Reddit, or Slack. But it can take hours to get an answer, and that’s a best-case scenario. It can take days if people need more information from you to help. In the worst case one of the following occurs:

  • No one answers the question.
  • Someone makes you feel stupid, telling you to use Google or read the documentation.
  • The moderators remove your question.

Wouldn’t it be great if you could fix the errors in minutes instead of waiting hours or days for others to help?

Learn How to Fix the Errors in Your Swift Code

I’m writing a book, Fixing Swift Code, that will help you find and fix the errors in your Swift code. You’ll learn the following in the book:

  • What Xcode’s build error messages really mean
  • How to fix your code so your project builds
  • How to find where your app crashes
  • The most common causes of app crashes and how to fix them
  • How to prevent crashes with Swift optionals

After reading Fixing Swift Code you’ll be able to get your app to build successfully and run without crashing. Spend more time making your app and less time asking questions and waiting for answers.