In my case, this happened when I had an environment variable set manually for the project via the scheme.
What caused it was an accidentally added environment variable without a name or value.
(Check for it under Product > Scheme > (pick a scheme), select Run from left nav, and inspect the manually configured environment variables.
This won't be the cause for everyone, but the empty name/value pair for the env var definitely is a cause for this error (easily reproducible)