Well, I solved this issue going back to a previous version stored in Time Machine, deleting all certificates and profiles both on Developer website and computer, deleted files in ~Library/MobileDevice/Provisioning Profiles and the certificates stored in Keychain Access. Also checked in project.pbxproj that no PROVISIONING_PROFILE was set.
Then, I loaded the old version in Xcode and I was able to build and archive it.
After that, the newest version worked again.
By the way, if you try to distribute an app to a device running iOS 7.1, read this