Skip to content
mutastic

Swift edition

Xcode projects

Most Swift code lives in apps, and apps are Xcode projects with XCTest more often than packages with Swift Testing. mutastic runs an Xcode project’s or workspace’s tests on a Mac, the way Xcode does, with a few changes so a run never touches your own build or needs your signing identity.

  • The scheme: the only shared scheme with tests for macOS or iOS. A project with several stops and lists them; --scheme names the one to use. A scheme’s test plan is read for which test targets run and which tests they skip.
  • The platform: macOS when the scheme’s tests run there, else the iOS Simulator, on an iPhone of the newest iOS the Mac has, one already booted first. Tests for watchOS, tvOS or visionOS are refused by name: choose a scheme whose tests are for macOS or iOS.
  • The files mutated: the Swift files of the targets the scheme’s tests test.

Every mutant is written into a copy of the project, as for a package, and the copy is built once with xcodebuild build-for-testing. Each mutant’s tests then run with xcodebuild test-without-building, one -only-testing for each test it needs. The build:

  • goes in .build/mutastic/derived-data, never your own DerivedData;
  • is built with signing off (CODE_SIGNING_ALLOWED=NO), so it needs no certificate;
  • runs iOS tests with parallel testing off, as Xcode’s simulator clones take minutes and gigabytes each.

An Xcode project takes longer than a package: the build, the simulator and xcodebuild’s start-up each cost time, and a mutant’s run starts xcodebuild again. Run it on the files you changed with --since, or split it across CI jobs with --shard.

  • scheme-ambiguous: several schemes have tests, and none was named: run again with --scheme and one of those it lists.
  • xcode-too-old: the project was saved by a newer Xcode than the one xcode-select points at.
  • runner-failed: xcodebuild ran none of the tests it was given, or couldn’t run them.
  • No simulator: the tests are for iOS and the Mac has no iPhone simulator; add one in Xcode.

Xcode projects need a Mac, as xcodebuild does.