Wednesday, September 11, 2019

Fix Rename Failed in Xcode 10

Running a refactor in Xcode can sometimes show "Rename failed" message. This can be fixed by quitting Xcode, cleaning derived data folder and doing a rebuild followed by the refactoring. Below is a script to clean the derived data folder.

# Clean Xcode cache

rm -frd ~/Library/Developer/Xcode/DerivedData/*
rm -frd ~/Library/Caches/*
After cleaning the caches, launch Xcode, build the project. Then wait for any indexing tasks to complete. Now try Refactor > Rename and this should work.