Creates a proxy for an application associated with the specified bundle identifier.


init(bundleIdentifier: String)


Use this initializer to launch an application based on its bundle identifier. For more information about bundle identifiers, see About Bundle IDs in the App Distribution Guide.

Although every app has an unique bundle ID, there are times when XCTest needs to decide which particular build of an app to use for testing. On macOS, multiple builds of the same app can exist on a single device. On iOS and tvOS, a build of the app may need to be copied onto the device for testing. In both cases, XCTest detects a matching build to use in the following order, based on the current test scheme selected in Xcode.

  1. Any matching build in the "Target Dependencies" list of a test target built by the test scheme.

  2. Any matching build from the "Targets" list of the test scheme's "Build" action.

  3. Any matching build from the root level of the test target's Build Products folder.

For iOS and tvOS apps, the matching app build (if found) is installed onto the device and launched. If no matching app is found, the device's existing installed app for the requested bundle ID is launched.

For macOS apps, the matching app build (if found) is launched from its existing location. If no matching app build is found, the default app build on the device for the requested bundle ID (as determined by Launch Services) is launched.

See Also

Creating an Application Proxy


Creates a proxy for the application specified as the "Target Application" in Xcode's target settings.

init(url: URL)

Creates a proxy for the application at the specified file system URL.


Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software