Code completion not working in 10.2

With the 10.2 update, I cannot get code completion working in one of my projects. I've reinstalled Xcode. I've nuked the repo and pulled it down again. I've deleted derived data. I've turned auto-complete on and off - and still nothing.


Other projects work, but there is no indication why this specific project keeps failing to provide auto complete


It says "indexing" for a hot minute and it doesn't seem to be indexing anything correctly.

I have the exact same problem. I had this issue with Xcode 10.1 with another project. The only thing that helped was starting a new project and add all files from the disk again. Painful if you have multiple targets like me 😟


It gets really annoying now.

Did you do a Clean Build Folder, forcing some reindex.

Yes I did, but it does not help. The usual tricks do not help:

- Clean build folder

- Delete derived data

- Close/reopen Xcode

- Restart mac


As I noticed Xcode is likely to mess up the pbxproj file, specifically some references in it.

OK, I've found a solution:

Xcode can mess with pbxproj file and can:

- break references

- leave obsolate references dangling


Close Xcode. Save your pbxproj file for sure.


I downloaded this tool: https://github.com/americanexpress/xcprojectlint


~/xcprojectlint --project XXXX.xcodeproj --report error  --validations files-exist-on-disk


You should be watching for output like this:


/project.pbxproj:0: error: XXXXX/Vendor references files that are not on disk.


Open the the pbxproj file and search for the folder indicated above (Vendor). Check all references under children of it and delete all obsolate ones.


Clean DerivedData. Open the workspace again. Try to compile. Fix any errors. Re-add missing files is needed.


The sad thing is that Xcode does not always fully follow up refactors, moving files/folders. The project still compiled though, but after fixing the pbxproj file many errors occured. This can be dangerous, so using xcprojectlint help a lot.

Did you try converting your project to Swift 5 ?

I do not get why it should help. Definitely the pbxproj file was "corrupted".

May be the lib called by API are different.

Xcode 11.6

I was able to get this working by removing subFolders in my project and leaving all in the main Folder.

Example:
my apps MAIN folder i had another folder inside called HOME, this made it that nothing in the HOME folder autocomplete,

I had to remove the files from the HOME folder and just leave them in the MAIN app folder and was able to get Autocomplete working again
Issue persists in Xcode 11.5 and 11.6 as well.

Only solution that seems to work is to move the current file into the main folder from any of the sub-folders.
Auto code completion will work fine only for files in the main folder of the app.
Once the changes are complete in the current file, it can be moved back into the sub-folder, if needed.

Very annoying sometimes.
Code completion not working in 10.2
 
 
Q