How to pass iOS launchOptions in AppDelegate from appium?

I’d like to pass some initial parameters to the iOS app to do some additional work for testing on the app side. I guess AppDelegate’s didFinishLaunchingWithOptions: is the best place and I thought it can be done by setting processArguments capability on the appium side according to this thread. However it doesn’t work and launchOptions is always nil. What am I missing?

processArguments I set looks like this:

"processArguments": {"args" : ["a", "b"], "env" : {"c":"d"}}

The log on the appium server looks like this:

[debug] e[35m[BaseDriver]e[39m W3C capabilities and MJSONWP desired capabilities were provided
[debug] e[35m[BaseDriver]e[39m Creating session with W3C capabilities: {
[debug] e[35m[BaseDriver]e[39m   "alwaysMatch": {
[debug] e[35m[BaseDriver]e[39m     "platformName": "iOS",
[debug] e[35m[BaseDriver]e[39m     "appium:appPackage": "com.myapp",
[debug] e[35m[BaseDriver]e[39m     "appium:bundleId": "com.myapp",
[debug] e[35m[BaseDriver]e[39m     "appium:xcodeOrgId": "***",
[debug] e[35m[BaseDriver]e[39m     "appium:xcodeSigningId": "iPhone Developer",
[debug] e[35m[BaseDriver]e[39m     "appium:name": "***",
[debug] e[35m[BaseDriver]e[39m     "appium:automationName": "XCUITest",
[debug] e[35m[BaseDriver]e[39m     "appium:processArguments": {
[debug] e[35m[BaseDriver]e[39m       "args": [
[debug] e[35m[BaseDriver]e[39m         "a",
[debug] e[35m[BaseDriver]e[39m         "b"
[debug] e[35m[BaseDriver]e[39m       ],
[debug] e[35m[BaseDriver]e[39m       "env": {
[debug] e[35m[BaseDriver]e[39m         "c": "d"
[debug] e[35m[BaseDriver]e[39m       }
[debug] e[35m[BaseDriver]e[39m     },
[debug] e[35m[BaseDriver]e[39m     "appium:deviceName": "iPhone 8 Plus",
[debug] e[35m[BaseDriver]e[39m     "appium:udid": "00003ADB-A875-4226-A120-ADAEE590D25E",
[debug] e[35m[BaseDriver]e[39m     "appium:platformVersion": "14.2"
[debug] e[35m[BaseDriver]e[39m   },
[debug] e[35m[BaseDriver]e[39m   "firstMatch": [
[debug] e[35m[BaseDriver]e[39m     {}
[debug] e[35m[BaseDriver]e[39m   ]
[debug] e[35m[BaseDriver]e[39m }
  • Platform you are automating (iOS or Android): iOS (React Native)
  • Appium version: v1.19.0
  • Simulator/Emulator or Real Device: Simulator
  • The language you are using for writing tests (client binding): Python
  • Your OS: macOS 10.15.7

I haven’t confirmed and not sure about your app code, but did you tried like https://nemecek.be/blog/20/ios-13-launchoptions-always-nil-this-is-the-reason-solution ?

@KazuCocoa Thank you! I’ll take a look

@KazuCocoa I found I made a mistake. I should have retrieved the "appium:processArguments" via ProcessInfo.processInfo.arguments or ProcessInfo.processInfo.environment not the launchOptions in the didFinishLaunchingWithOptions: function.
https://developer.apple.com/documentation/foundation/processinfo

I succeeded to get the process arguments in the initial process of React Native app.
Thanks for your support.