[FIX-Tutorial] How to solve common Xcode Issues - Unblock Workflow

Hey Everyone!

I am sure many of us have faced issues with Xcode during our workflow and the experience is not great! It gets frustrating at some point and we get clueless to what must be done! In most cases, these issues occur during a 'git pull', 'rebranching', etc, any sort of general changes to your codebase, or sometimes even randomly show up.

While most can be found online via common forums (like StackOverflow), sometimes none works, and even if you delete the project folder, rebuild, things just don't work as normal!

[General] Fixes (which I am sure you found across the internet):

  • Delete ~/Library/Developer/Xcode/DerivedData
  • Clean Build Folder - Command + Shift + K

(If none of above works, try resetting Xcode by, 'defaults delete com.apple.dt.Xcode')

[Target and Scheme Related] Magical Fixes!
(Always works!)

(This fixed the Xcode Syntax Colouring, Code Completion, Type Hints, Errors, Jump to Definition and many more!):

  • Switch your existing scheme to swift-frontend, which is among the generated Xcode Targets when you had added files from Swift.xcodeproj during setup
  • Build with this scheme, yes it fails, but this fixes the complete Xcode Codebase
  • Switch back to your original scheme and maybe thank me later :)

You may be wondering why this works, well its because, Xcode gets confused due to multiple targets and schemes and doesn't recognise the files across the project, and behaves quite weird, like a very common one is, when you start typing, random 10+ errors show up, although compilation is successful!

(Doing this, helps Xcode recognise those files and fix its internal working.)

@anthonylatsis Do you think this could potentially be added to 'GettingStarted.md' and/or any appropriate places?


1 Like

Instead of building, I recommend just static analysis. This action can be started via the "Analyze" item under the "Product" menu:

or the "Analyze" option after holding on the ":arrow_forward:︎" button:


The analysis takes a rather long time to complete, but afaiu unlike building, it does not stop after encountering errors.

1 Like

That's nice too! It's actually more concrete and better in terms of the process and understanding as a whole, cause 'analyse' is meant for bug fixing and testing!

Apart from the time constraint, sounds good!