How can I diagnose save file issues in Xcode and on my desktop? There is something wrong about my mac (macOS sierra) , and it's happening for about 2 weeks , for example:

I'm working with Xcode and suddenly i can't save any file, and I go to desktop , can't copy paste any item .
I don't remember any error but I could not modify or create new file on my macbook.
I would first boot to recovery mode - run Disk Utility until you have a clean filesystem.

At that point, I would try again using three apps - if all three apps can't write a simple text file to your desktop - it's going to be an account permissions issue.

The problem with user permissions is you'll need a new and functional admin account to fix things.

If you have a good backup - you could wipe the system, make a new admin account and then migrate things back. That would typically fix any permissions issues when you re-create the new user in the new home folder.

Alternatively, you could boot to single user mode and remove the /var/db/.AppleSetupDone file and then boot your "broken" system and run through the setup assistant. Make a new admin with a new name like "new admin" and then use that admin account to delete and re-create your old admin user.

Sorry for the vague steps - you will need to have a troubleshooting / triage effort to nail down what specifically is failing and then ask a follow on question if you don't already find an answer here how to recreate a user, how to make a new admin account, etc...