You can get access to those launch arguments and environment variables via NSProcessInfo
if NSProcessInfo.processInfo.arguments["DEBUGRPM"] ...
That's not unreasonable and allows you to change the behavior of a compiled app which can be useful in some cases. It does however have some overhead since you're always performing this check. If you would only ever enable debug logging in a debug build then setting a value in "Swift Compiler - Custom Flags" (as shown in the question @Larme linked) and using an #if DEBUGRPM
expression will give you conditionally compiled code, saving the app the work of performing a runtime if
test.
Which approach is more reasonable for you will depend on how you plan to use and when you plan to toggle this behavior.