XCTestPlan environment variable not retrieved in xcode 26

I have an environment variable set in an xctestplan for a set of unit tests that I access like so:

let testType = ProcessInfo.processInfo.environment[TARGET_TEST_TYPE_KEY]

This is always is always returning nil when I run my unit tests in Xcode 26, but seems to work as expected in Xcode 16.4. Were there any changes in Xcode 26 that changes how this works?

Thanks in advance.

There are no known issues around this in Xcode 26. If you are using XCTest UI Automation style tests, please ensure you are accessing environment variables set in a test plan from your test runner process and not from the process of an app-under-test.

If you believe this is a regression, please file a Feedback with Apple and include the .xcresult bundle from Xcode's Report navigator if possible.

Accepted Answer

Ok, I think I got it to work. I think I was using the wrong build scheme. It appears to work when selecting the test scheme in xcode before running the tests. I think previously xcode would automatically switch schemes, or at least a prompt would appear asking if I wanted to switch schemes, I could be wrong, though.

Thanks.

XCTestPlan environment variable not retrieved in xcode 26
 
 
Q