Xcode 8 going slow on Swift 3? Try “repotting” your project

TLDR: If your project is going slow, then create a new one and copy your old files in. I share my experience of the process that worked for me.

Image for post
Repotting plants is great for speeding up growth

I am sure that there are a lot of you out there who are struggling after upgrading to the latest and greatest Xcode 8. I have seen (and experienced ) the following:

  • Crawlingly slow Compile times of between 15 seconds and 1 minute
  • Wierd errors which forced me to repeatedly clean and rebuild projects
  • Autocomplete taking up to 20 seconds before showing up and even then being quite hit an miss.

I found that I was absolutely hating developing in Swift 3 with my personal project I am working on taking ages.

The camel’s back was finally broken when my tests just suddenly stopped running altogether with the following strange “ungoogle-able” error code:

xctest configuration; error: You don't have permission.

I tried everything and it was in the garden that I thought of an idea. What if I “re-potted” the project. For those that don’t know you repot a plant when:

“the roots get too big for the pot and the plant slows its growth or stops growing altogether” — Guide to Houseplants

Just like my xcode project…..

So when I got in I did the following steps which restored my project’s compilation speed and xcode autocompletion to down to a bearable second or two

How to “Re-pot” your Xcode project to make it faster in Xcode 8 for Swift 3

  1. Create a new project in a new folder using Xcode 8.
  2. Create a new Podfile project using pod init if you are using Cocoapods
  3. Copy across your pod files configuration and pod install

You should now have a blank project with your pods included.

  1. Copy across your project files (except test files, and supporting files like assets, Storyboard and App Delegate) in groups of 3–5.
  2. For files like App Delegate I copied the contents of the body directly using Xcode
  3. For Assets, I dragged the folder contents for it to the new project
  4. Don’t copy across your new test files yet but just go ahead and just do a project clean and build.

You should now see that your project is blazingly fast.

  1. Add the test files back in 1 or 2 at a time. Its here that I got a pretty horrendous set of errors. I noticed that I had to clean my project build folder (Hold down the Alt key and select Project-> Clean Build Folder) several times in this step of the process which I put down to some xcode bug.
  2. Once you are done, copy the files over to your git repos and carry on coding!
Image for post
After repotting your project should be faster and can grow nicely again

Hopefully at the end of this process you will have a faster Xcode project for enjoying your swift 3 goodness. ( and maybe you have learned a little about gardening at the same time!)

Personally I hope that Apple will sort out Xcode 8 and get it working properly again with less bugs, but given their problems with the new MacBook Battery maybe they should focus on getting more people like us in to help them identify these problems so they can get rid of them for us.

Hope this process helps others out there…Happy Xcode Gardening.

Edit: As a by-product this also fixed the bug with Xcode Tests not running with the message:

Message from debugger: unable to attach

Image for post