March 7, 2021
Launch arguments are options that are send to your app on launch.
It’s helpful in case like:
Select your target and select “Edit scheme…”.

Then add your arguments within the “Arguments Passed on Launch” dropdown.

if CommandLine.arguments.contains("-reset") {
  ...
}
func testRemovingContact() {
  let app = XCUIApplication()
  app.launchArguments = ["-reset", "-skipOndoarding"]
  app.launch()
  ...
}
struct LaunchArgumentsHandler {
  func handle() {
    resetIfNeeded()
  }
  private func resetIfNeeded() {
    guard CommandLine.arguments.contains("-reset") else {
      return
  }
  ...
}