I have the exact same problem. Why do "they" think Pages is a code editor? Have you figured out how to change to BBEdit?
Xcode is a bit of a hot-mess when it comes to working with files as it tries to treat source code editing like using Safari. You basically have to use the Finder to open the files and manage files easily.
Like you would in Windows, set the default application for each file extension to open to BBEdit. Select a file with a given Windows extension aka ending in one of '.c', '.cp', '.m', '.h', '.swift' etc. Then select "Get Info". In the Get Info window, under the "Open with:" you would select the editor you want, in this case BBEdit. Then press the "Change All..." Do that for a file ending in each extension in files where your code might reside.
If you option-drag (make a copy for safety) each file with the unique windows extension to the Desktop, you can then select all of the files and use option-command-I to open what ammounts to a single Get Info window ("Inspector) and then change the defaults for all of them with one action.
(I'd show you with a couple of snapshots but this forum is lame... sorry)