Skip to content

apple_test_bundle

Apple test bundle.

Description

Builds Apple test targets and runs XCTest or Swift Testing tests through the generic Once test capability. Attributes whose names contain sdk configure the Apple software development kit (SDK) used for the build.

Attributes

AttributeTypeRequiredDefaultDescription
platformstringyesApple platform for the tests
minimum_osstringno13.0Minimum supported operating system version
target_sdk_versionstringnominimum_osSoftware development kit version used in the target triple
sdk_variantstringnosimulatorsimulator or device; ignored on macOS (not configurable)
xcode_developer_dirstringnoactive XcodeXcode developer directory used to resolve build tools
product_namestringnotarget nameTest bundle product name (not configurable)
test_hosttargetnoApplication target hosting the test bundle
resourceslist<string>no[]Resource glob patterns bundled into the test bundle
asset_catalogslist<string>no[]Asset catalog paths compiled into the test bundle
info_pliststringnoInfo.plist template path
entitlementsstringnoEntitlements plist path
destinationstringnoSimulator, device, or local destination selector
test_planstringnoXCTest plan path
test_envmap<string,string>no{}Environment variables passed to the test runner
swift_flagslist<string>no[]Extra Swift compiler flags
swift_testingboolnofalseRun sources that use Swift Testing (import Testing) through the generic Once test capability
labelslist<string>no[]Agent-readable labels used for filtering or policy

Dependency Edges

EdgeAcceptsDescription
depsapple_linkable, apple_application, apple_swift_plugin, native_linkableCode under test, optional host application, native linkables, and Swift compiler plugins

Providers

The target emits apple_test_bundle, apple_bundle, and once_test_info.

Capabilities

CapabilityOutput groupsRequires
builddefault, bundle, dsyms
testdefault, test_results, coverage

Outputs

OutputLocation
Test bundle.once/out/<target>/<product_name>.xctest
macOS test binary.once/out/<target>/<product_name>.xctest/Contents/MacOS/<product_name>
Other Apple platform test binary.once/out/<target>/<product_name>.xctest/<product_name>
macOS property list.once/out/<target>/<product_name>.xctest/Contents/Info.plist
Other Apple platform property list.once/out/<target>/<product_name>.xctest/Info.plist
macOS code signature.once/out/<target>/<product_name>.xctest/Contents/_CodeSignature/CodeResources
Other Apple platform code signature.once/out/<target>/<product_name>.xctest/_CodeSignature/CodeResources
Test results.once/out/<target>/test/test_results.json after once test
Test log.once/out/<target>/test/swift-testing.log for Swift Testing or xctest.log for XCTest
Native runner output.once/out/<target>/test/native_results.txt

Limitations

App-hosted tests, resource bundling, asset catalogs, custom property-list templates, entitlements, destinations, and test plans are unsupported. The target rejects non-empty values for those attributes instead of ignoring them. Test execution is limited to macOS logic tests and iOS simulator bundles.

Example

toml
[[target]]
name = "AppTests"
kind = "apple_test_bundle"
srcs = ["AppTests/Sources/*.swift"]

[target.attrs]
platform = "macos"
minimum_os = "17.0"
swift_testing = true
labels = ["swift-testing"]

Released under an open-source license.