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.
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:
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
- Create a new project in a new folder using Xcode 8.
- Create a new Podfile project using
pod initif you are using Cocoapods
- Copy across your pod files configuration and
You should now have a blank project with your pods included.
- Copy across your project files (except test files, and supporting files like assets, Storyboard and App Delegate) in groups of 3–5.
- For files like App Delegate I copied the contents of the body directly using Xcode
- For Assets, I dragged the folder contents for it to the new project
- 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.
- 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.
- Once you are done, copy the files over to your git repos and carry on coding!
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