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
  • EXC_CRASH (SIGTRAP)
  • 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.

Do You Want a Discount on the Book?

Fill out the form below. You’ll also get exclusive articles and a guide on going from tutorials to making your first app.