Create and run unit tests, performance tests, and UI tests for your Xcode project using XCTest.

Posts under XCTest tag

71 Posts

Post

Replies

Boosts

Views

Activity

Code Coverage Not Generated in Xcode 26.1 Despite Successful Test Runs
We’re facing an issue with Xcode 26.1 where code coverage is not being generated. All our test cases run and pass successfully, but the .xccovreport / .xccovarchive files are never produced. Code coverage is enabled in the scheme, and this setup used to work correctly in earlier Xcode versions. We are trying to determine whether this is a configuration issue on our end or a possible Xcode 26.1 bug. Is anyone else experiencing the same problem with code coverage in Xcode 26.1? Any insights or workarounds would be appreciated.
1
0
36
2h
XCTFail immediately aborts the test in Xcode 26 — no retry on failure
Hi, I’m seeing an unexpected change in how XCTFail behaves in UI tests after updating Xcode. I use the following helper method: `func waitForExistance(file: StaticString, line: UInt) -> Self { if !(element.exists || element.waitForExistence(timeout: Configuration.current.predicateTimeout)) { XCTFail("couldn't find element: \(element) after \(Configuration.current.predicateTimeout) seconds", file: file, line: line) return self } else { return self } }` In Xcode 16.4, this worked as expected: – when an element wasn’t found, XCTFail was triggered, but the test continued running, allowing my retry logic to execute. After updating to Xcode 26.1 / 26.2 - the test now immediately aborts after XCTFail, without executing the next retry. The logs show: `t = 113.22s Tear Down t = 113.22s Terminate com.viessmann.care:81789 *** Assertion failure in -[UITests.Tests _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:], XCTestCase+IssueHandling.m:273 Test Case '-[UITests.Tests test_case]' failed (114.323 seconds). Flushing outgoing messages to the IDE with timeout 600.00s Received confirmation that IDE processed remaining outgoing messages` It looks like XCTFail in Xcode 26 is now treated as an unhandled developer exception, which stops the test execution immediately, even when it’s called inside a helper method. This was not the case in earlier versions. My questions: Is this a regression in XCTest? Or an intentional change in how XCTFail behaves in newer Xcode versions? Should failures now be reported differently (e.g., using record(.init(type: .assertionFailure, …))) if I want to continue the test instead of aborting it? I would like to restore the previous behavior where the failure is logged without terminating the entire test, so my retry mechanism can still run. Has anyone else run into this after upgrading? Thanks in advance! If you’d like, I can also add recommended workarounds that actually work with Xcode 16.4 (e.g., replacing XCTFail with a non-terminating issue record).
2
2
101
1d
XCTest doesn't return the elements in navigation bar after iOS 26 upgrade
The buttons in the navigation bar are not available in the element tree after iOS 26 upgrade of the test phones. The same IPA version, the same XCode version, but different trees on different phones. There is no way to automate UI testing for these missing buttons. # ios 18 NavigationBar, 0x108e0c3c0, {{0.0, 47.0}, {390.0, 44.0}}, identifier: 'Profile' Button, 0x108e0c500, {{8.0, 47.0}, {43.0, 44.0}}, identifier: 'UserProfileSceneViewController_profile_back_button', label: 'chevronLeftIcon' StaticText, 0x108e0c640, {{169.3, 58.0}, {51.3, 22.0}}, label: 'Profile' Button, 0x108e0c780, {{339.0, 47.0}, {43.0, 44.0}}, identifier: 'UserProfileSceneViewController_settings_bar_button', label: 'Settings' # ios 26 NavigationBar, 0x13d63c8c0, {{0.0, 47.0}, {428.0, 54.0}}, identifier: 'Profile' StaticText, 0x13d63ca00, {{188.3, 58.0}, {51.3, 22.0}}, label: 'Profile'
1
1
161
3d
Failed to generate code coverage report on iPhone
Failed to generate code coverage report when doing Swift Testing on iPhone device, but it's ok in UI testing or running on "My Mac(Designed for iPad)". I have enable code coverage in test plan. My app can't run on simulator due to frameworks limitations. Platform: Mac mini M2 w/ macOS15.7, iPhoneXR 18.6.2 Xcode version: 26.1 & 16.0 error msg: Failed to download profiles from paths ["/private/var/mobile/Containers/Data/Application/76A1F9BC-98C8-4349-998B-0FC030DEE3EC/tmp/3A424286-872D-40AD-B4CA-65B232B57EB4"] on device 'iPhoneXR' for application with bundle ID 'xxx.xxxx.xxxx' to directory /Users//Library/Developer/Xcode/DerivedData/-bosqsqmqiqwweldrfrtgsfpnhroht/Build/ProfileData/00008020-00042C2A3E38002E: Failed to retrieve the file node for tmp/3A424286-872D-40AD-B4CA-65B232B57EB4. (Underlying Error: Failed to retrieve the file node for tmp/3A424286-872D-40AD-B4CA-65B232B57EB4)
0
0
64
3w
SwiftUI .toolbar(placement: .keyboard) item not exposed to accessibility on iOS 26.1 (affects VoiceOver + XCUITest)
Description On iOS 26.1, a ToolbarItem placed in .keyboard is no longer exposed to the accessibility hierarchy. As a result: VoiceOver cannot focus or activate the toolbar button XCUITest cannot discover the element, making the UI impossible to test TextEditor() .toolbar { ToolbarItem(placement: .keyboard) { Button("Done") { /* action */ } } } This worked correctly on previous iOS versions. The button appears visually but is missing from both VoiceOver navigation and XCUI accessibility queries. Steps to Reproduce Create a new SwiftUI project. Use a simple text field with a keyboard toolbar button. Run on an iOS 26.1 device or simulator. Focus the text field to show the keyboard. Turn on VoiceOver and attempt to navigate to the toolbar button. Run an XCUITest attempting to locate the button
1
0
73
3w
Report Navigator Arrow Icon Missing in XCResult Files Since Xcode 16.4
After upgrading to Xcode 16.4, the navigation arrow icon in the Report Navigator is no longer appearing for failed test cases within XCResult bundles. This icon, which allows developers to directly navigate to the specific line of code that caused a test failure, is now missing. This significantly hinders the debugging process for test automation engineers. Details: Xcode Version: 16.4 (issue started after upgrade) Test Framework: XCTest Test Environment: iOS simulators Execution Method: The tests are executed on a Jenkins CI/CD server XCResult Analysis: The generated .xcresult bundle is downloaded from the Jenkins server and opened locally on a Mac also running Xcode 16.4. Observed Behavior: The navigation arrow icon is missing, and there is no direct way to jump to the failure line from the report. This issue appears to be a regression introduced in Xcode 16.4, as the navigation arrow was consistently present in previous versions. Any insights or workarounds would be greatly appreciated.
2
2
114
Nov ’25
UI Testing and 'Allow Paste'
I am developing an app that allows the user to ask it to process the clipboard contents and do something with it. In developing a XC UI Test, I find the app stops while it waits for the user to give permission. That breaks the automation. I tried: let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") let allowButton = springboard.buttons["Allow Paste"] But that does not work. Is there a way to tell the framework to automatically give the test permission to access the Paste clipboard (or to allow me to write tests to grant this)?
0
0
57
Nov ’25
iOS 26.1 simulator prompting Apple ID login during XCUITest
Hello Apples, Noticed that after iOS 26.1 update the Xcode simulator seems to be prompting to login with Apple ID arbitrarily while working on some UI tests. This does not happen with previous iOS 26.0 or 26.0.1 but is now causing trouble when launching the app or uninstalling at teardown. The current other issue with the uninstallation being sticky and taking a long time (waiting for springboard to become idle) is not helping either. The dialog seems to appear a bit unreliably to be able to handle it correctly. Have tried both manual springboard dialog mapping and handling as well as an interruption monitor. The latter only seems to work for the first dialog which appears but then ceases to function so not much help… Anyone else seeing this and are there any knowledge or good workarounds? Or should we just roll back to testing with previous OS versions and cross fingers for iOS 26.2? Bottom line we cannot login with an Apple ID while running tests on a simulator… As bonus noticed the simulator background images are not working? Thanks! BR, ARu_ (Senior QE)
1
0
251
Nov ’25
Xcode 26: `IDERunDestination: Supported platforms for the buildables in the current scheme is empty` repeatedly logged when running tests from `.xctestrun` file
We are seeing repeated occurrences of the following log line in test runs triggered via .xctestrun files on iOS 26: IDERunDestination: Supported platforms for the buildables in the current scheme is empty. This line is printed n number of times after a test fails, significantly increasing test execution duration (2–3 minutes extra in some cases). The issue does not occur when tests are built and run together from Xcode directly — it’s specific to .xctestrun-based executions using xcodebuild test-without-building. Steps to Reproduce: Use Xcode 26 to build a sample XCTest target (we used a simple UI test project). Locate the generated .xctestrun file under DerivedData/.../Build/Products/.... Run tests using: xcodebuild -xctestrun /path/to/sample.xctestrun \ -destination "id=<device_id>" \ test-without-building Observe the logs during test failure. Observed Behavior: The log line IDERunDestination: Supported platforms for the buildables in the current scheme is empty appears multiple times. The test cleanup and teardown phase takes significantly longer (2–3 minutes). Expected Behavior: The log should appear once or not at all. Test cleanup time should remain consistent. Additional Information: Affects only iOS 26 devices and .xctestrun-based runs. Not reproducible on iOS < 26. Xcode 26 and 26.x beta versions tried. Reproducible both locally and on CI systems using real devices. Same .xctestrun file, when used on older OS versions, does not cause delay.
0
4
129
Nov ’25
Xcode 26 crash upon dealloc of `WKNavigationResponse` on Main Thread
Since Xcode 26 our tests are crashing due to the Main Thread not being able to deallocate WKNavigationResponse. Following an example: import Foundation import WebKit final class WKNavigationResponeMock: WKNavigationResponse { private let urlResponse: URLResponse override var response: URLResponse { urlResponse } init(urlResponse: URLResponse) { self.urlResponse = urlResponse super.init() } convenience init(httpUrlResponse: HTTPURLResponse) { self.init(urlResponse: httpUrlResponse) } convenience init?(url: URL, statusCode: Int) { guard let httpURLResponse = HTTPURLResponse(url: url, statusCode: statusCode, httpVersion: nil, headerFields: nil) else { return nil } self.init(httpUrlResponse: httpURLResponse) } } import WebKit import XCTest final class ExampleTests: XCTestCase { @MainActor func testAllocAndDeallocWKNavigationResponse() { let expectedURL = URL(string: "https://galaxus.ch/")! let expectedStatusCode = 404 let instance = WKNavigationResponeMock() // here it should dealloc/deinit `instance` automatically } Here the call stack: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 CoreFoundation 0x101f3dd54 CFRetain.cold.1 + 16 1 CoreFoundation 0x101e14860 CFRetain + 104 2 WebKit 0x10864dd24 -[WKNavigationResponse dealloc] + 52
7
0
1.1k
Oct ’25
Unable to launch tests in Xcode 26
I am trying to upgrade my app to use Xcode 26 and I cannot get my tests to launch. I am trying to launch tests to the simulator, and I always get this error after 300 second timeout: "encountered an error (The test runner hung before establishing connection.)" There are no other errors getting logged. I can run to the same simulator just fine, and in Xcode 16 the tests launch with no issues. The tests also run fine on an actual iPhone. Thanks in advance.
6
0
242
Oct ’25
Error in gathering code coverage in Xcode16
Fails to gather code coverage and throws this error Showing All Messages Failed to merge raw profiles in directory /Users//Library/Developer/Xcode/DerivedData/Receiver-ekqrbpsaciuxmlfslviajhoecyat/Build/ProfileData/0B0C6B69-FD46-4801-B106-56B7FCD44370 to destination /Users//Library/Developer/Xcode/DerivedData/Receiver-ekqrbpsaciuxmlfslviajhoecyat/Build/ProfileData/0B0C6B69-FD46-4801-B106-56B7FCD44370/Coverage.profdata: Aggregation tool '/Users/shwethamugeraya/Downloads/Xcode 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata' failed with exit code 1: warning: /Users/shwethamugeraya/Library/Developer/Xcode/DerivedData/Receiver-ekqrbpsaciuxmlfslviajhoecyat/Build/ProfileData/0B0C6B69-FD46-4801-B106-56B7FCD44370/2F4EFBF7-1CCF-4E9E-8FD6-482EEDB98B6C-34646.profraw: raw profile version mismatch: Profile uses raw profile format version = 4; expected version = 8 PLEASE update this tool to version in the raw profile, or regenerate raw profile with expected version. error: no profile can be merged
7
9
1.3k
Oct ’25
XCUITests not starting
Looking for a way to overcome this issue when starting UI tests that used to be working: Source was stale 337 times within the last 500 ms (12 (latestGeneration) != 22 (lastKnownShmemState)): CFPrefsPlistSource<0x600003004c60> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: ###/data, Contents Need Refresh: Yes) ... Failed to initialize for UI testing: Error Domain=XCTDaemonErrorDomain Code=18 "Timed out waiting for AX loaded notification" UserInfo={NSLocalizedDescription=Timed out waiting for AX loaded notification} Message from debugger: killed The environment is Xcode 16.3 with iOS Simulator 18.0. Not using the latest Simulator 18.4 because of another bug with network requests: https://developer.apple.com/forums/thread/777999
1
1
176
Oct ’25
Error reporting test coverage in Xcode 14.3.1
Xcode is throwing an error when attempting to report test coverage after running unit tests. Showing All Messages Failed to merge raw profiles in directory /{my project dir}/DerivedData/{my project name}/Build/ProfileData/A98EC493-3AB4-4B1C-B7FC-BC5D77B23EE3 to destination /{my project dir}/DerivedData/{my project name}/Build/ProfileData/A98EC493-3AB4-4B1C-B7FC-BC5D77B23EE3/Coverage.profdata: Aggregation tool '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata' failed with exit code 1: warning: /{my project dir}/DerivedData/{my project name}/Build/ProfileData/A98EC493-3AB4-4B1C-B7FC-BC5D77B23EE3/997F01E3-3735-4897-AE00-31EBB0A9E8D3-57885.profraw: invalid instrumentation profile data (file header is corrupt) error: no profile can be merged Anyone else seeing this issue?
15
1
5.3k
Oct ’25
XCTestPlan environment variable not retrieved in xcode 26
I have an environment variable set in an xctestplan for a set of unit tests that I access like so: let testType = ProcessInfo.processInfo.environment[TARGET_TEST_TYPE_KEY] This is always is always returning nil when I run my unit tests in Xcode 26, but seems to work as expected in Xcode 16.4. Were there any changes in Xcode 26 that changes how this works? Thanks in advance.
2
0
158
Oct ’25
XCode app testing on iPhone fills in iPhone storage
I run some tests for an iOS app, connecting the iPhone to my mac where the code resides. I notice that it fills the iPhone from system data, until the iPhone is full. I tried everything to remove the system data (I assume some logs from the XCode testing): reset network, restart the iPhone, remove the tested app, etc. Nothing works. I am stuck with having to erase all data on the iPhone and reinstall from scratch, which is very tedious. Any suggestions ? Thanks!
0
0
87
Oct ’25
Xcode 15 performance tests ignore baseline
I'm trying to write performance tests with Xcode 15, but it's not working: even though setting a baseline seems to work (baseline data files are created), Xcode seems to ignore that baseline altogether whenever the test is run. As a result, performance tests never fail, no matter how bad performance gets. The source editor persistently displays a “No baseline average for Time” message. Has anyone else encountered this? Figured out how to sidestep the issue? Of note, the issue is easily reproduced: create a new (macOS in my case) app project with tests, add a dummy performance test; run the test once and save its baseline, and despite this subsequent tests will always succeed, even if you significantly slow the dummy test down. (I've filed this as FB13330139)
11
10
2.7k
Oct ’25
Xcode Code coverage shows zero; even after 245 successful tests
I have a project inside the project structure. I have around 300 unit tests in the project. I see that for some of the subprojects, the coverage numbers show up correctly, but for other subprojects and the main project, the coverage number shows zero, even though the tests are running successfully. The log I get is: Aggregation tool emitted warnings: warning: /Users/ABC/Library/Developer/Xcode/DerivedData/projectABC-hfzmkbdgpiswoxfvvnvhrafaiqyb/Build/ProfileData/A8EEC1FB-1699-4C29-A88C-D3DDA226DBC0/0A416494-A393-4319-AA47-502D72084C9C-43351.profraw: raw profile version mismatch: Profile uses raw profile format version = 8; expected version = 10 PLEASE update this tool to the version in the raw profile, or regenerate the raw profile with the expected version. I only have one Xcode (26.0.1) on my machine. I tried cleaning the derived data, the cleaning project, and rerunning the tests, but it hasn't helped. Please help me get the coverage number back. Thank you.
0
0
91
Oct ’25
Code coverage. SwiftUI Wrong Executable Lines
Hi community: I noticed that each closure is counted as lines in code coverage (unit tests) (Xcode 14.1.0) in a swiftUI File. I mean, If you coded and VStack that involves another HStack, and HStack contains 4 lines, and the VStack contains 6 lines counting the HStack. The total executable lines should be 6 (6 lines in the file). But Xcode count 10, counting twice the HStack lines. Is it a bug, or is it correct? You know, I don't know if Apple has another concept about executable lines. Also, Is it possible to remove previews with any configuration from code coverage or constant files? Thanks for all.
1
2
825
Sep ’25