Today, I’d like to leave a tip. I’ve implemented test cases using this article for over 3 years. It helped us to control test environment more stable and fast.
XCUITest can set process arguments for Instrumentation.
According to https://github.com/appium/appium-xcuitest-driver#desired-capabilities, you can set processArguments in capability and the test app can get the value via ProcessInfo.
You can set the value via below’s Environment Variables.

Client
Next code is Ruby based.
IOS_OPS = {
caps: {
platformName: :ios,
automationName: 'XCUITest',
...
processArguments: {
env: {
"PROCESS_VALUE": "process value"
}
}
},
appium_lib: {
...
}
}.freeze
By processArguments, you can set the environment variables.
Test app
The processArguments can get via ProcessInfo like below.
import Foundation let env = ProcessInfo.processInfo.environment env["PROCESS_VALUE"] // "process value"
Next image isn’t the above. But I believe it help you understand ProcessInfo.processInfo.environment.
You can control some behaviour using the argument. For example, URLs or interval for network.
[update]
Android has optionalIntentArguments to give intent arguments in start activities.