Xcode: Operation not permitted

When I tried to use the new Xcode-beta.app, Xcode has rejected to compile and shown error message as "Operation not permitted".

Xcode: Operation not permitted

When I tried to use the new Xcode-beta.app, Xcode has rejected to compile and shown the following error message.

App Workspace: Error: The operation couldn't be completed. Operation not permitted.
The error message

This has pulled my head for two whole days... Turns out that all you need to do is

xattr -d -r com.apple.quarantine /Applications/Xcode-beta.app

to remove the com.apple.quarantine attribute which exists because it is downloaded from internet. Previously it failed to launch due to Gatekeeper acting weirdly, so I have removed such attribute manually from the binary file and Xcode has launched correctly. However there's plenty of developer tools under such .app file and the attributes on them also needs to be removed before it could be executed.