Inorder to update xcode using the new apple id you need to remove the old credentials from the AppStore with which the app was downloaded, to do that you need to remove the _MASReceipt directory from the application.
To do this:
- Open Finder and navigate to Applications,
- Click XCode and right click to choose “Show Package Contents”,
- Expand the Contents directory and click _MASReceipt to select it,
- Type Command+Delete of right click and ‘Move to Trash’ to delete the directory permanently—you will be prompted for your credentials since this is a protected file.
- Provide the password of the system.
- Quit and restart AppStore, then find XCode.
- Then update the xcode by clicking the “Update” button.
- Provide the new apple id and password.
It will update your XCode to the latest version as the currently logged-in Apple user.