I used to have this issue sometimes after restarting my computer, even though the permissions were correct. What fixed it for me was:
Closing xcode
Cleaning out the Derived Data folder, which you can usually find at ~/Library/Developer/Xcode/DerivedData
.
Reopening the .xcworkspace
file.