What kind of flag should be raised when we see a questions such as: How to randomly select a String in Swift (no code questions - asking for us to write code).
You are making a (false) assumption that questions asking how to do something without including an attempt to solve the problem are inherently off-topic.
You are wrong.
The only questions that explicitly require code are debugging questions. Those questions require an MCVE (Minimal, Complete, and Verifiable example) in order to be on-topic.
How-to questions do not require code. Including a failed attempt in a how-to question turns the how-to question into a debugging question. Contrary to popular belief, Stack Overflow is not solely a code debugging service.
How-to questions can be too broad, unclear, primarily opinion based, or off-topic for other reasons, but they are not off-topic just because they don't include a failed attempt to solve the problem.
Some of the most useful questions on this site are short how-to questions that do not include an attempt to solve the problem.
I generally leave a comment telling them that SO is not a code writing service, and that we need to see so far.
This is also incorrect. Contrary to popular belief Stack Overflow is a code writing service. We write code for people, all day long, all night long, and everything in between, on-top, beside, and underneath. We write code, that's what we do. If we aren't a code writing service, what are we?
Is there a set flag that should be raised, should we leave a comment, or should we add a flag for questions without code?
No, there is no "One Flag To Rule Them All". If an existing close reason applies to a question, use it... after you do everything else you can do to improve the question.
Yes, you should leave a comment if you want to ask for clarification or more information, or to inform the user of how you believe that they can improve their question.
No, we should not add a flag for questions without code, that is nonsense.