Xcode loads xcspec files (ascii plists) that specify everything (tools, buildphases, compilers, rules, etc) based on a set of conditions.
To evaluate these conditions you have to load these files and simulate the build process and construct your own "environment"
The target's build settings will help to resolve most of the environment variables by taking the basics from the
particular platform you are using for the target (resolved from the SDKROOT value xcrun --show-sdk-platform-path --sdk
)
when you load the spec of the compiler there is a key on it called "Options" which is an array of dictionaries that have