Apple should not allow Baidu to distribute a malicious version of Xcode. Apple should know that Baidu is distributing Xcode. Then some Apple employee should check this Xcode whether it is the original. Problem solved!
Wrong. Apple cannot check every source of Xcode; it could get passed around on a thumb drive. What Apple can do is make sure that only legitimate versions of Xcode can be used to compile apps that are sold the app store. Time to improve the digital signature process. If Apple cannot control that, maybe developers can upload the codebase to Apple and the last compilation can be done on their servers.