Latex: Listings with monospace fonts
What happens when you drop \usepackage{microtype}
? It messes with kerning and so forth and might be the cause of the problem, which I assume is due to the poor alignment.
The problem is the columns=flexible
option. Remove it and it looks like you want it to look. At least, if there is no actual reason for you to use it. If there is, there is no way to have the monospaceness of your snippet to look like in Xcode :).