XCTest - XCUIApplication's launchArguments does not correctly treat an argument with a linebreaks as a single argument

Originator:liam.nichols.LN
Number:rdar://FB16533842 Date Originated:2025-02-20
Status:Open Resolved:
Product: Product Version:
Classification: Reproducible:
 
When using `XCUIApplication`’s `launchArguments` array to pass arguments into the application being tested, arguments that contain line breaks (i.e `\n`) are incorrectly escaped and become split across the line break when the app tries to read them from `ProcessInfo.processInfo.arguments`.

- Download the LaunchArgumentBugDemo.zip attachment
- Unzip the Xcode project and open it
- Hit CMD + U to run the tests
- Observe that testWithMultilineString() fails with the following error:

> XCTAssertEqual failed: ("This is a") is not equal to ("This is a
multiline string!")

In the demo app, the following value is passed into the `launchArguments` array:

```
let contents = """
This is a
multiline string!
"""

let app = XCUIApplication()
app.launchArguments = [contents]
app.launch()
```

The expectation is that `ProcessInfo.processInfo.arguments` should contain an argument with the value `”This is a\nmultiline string!”`, but the test fails because the array actually contains two arguments `”This is a”` and `”multiline string!”`. This is not expected.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at feedbackassistant.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!