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)
XCTest
RSS for tagCreate and run unit tests, performance tests, and UI tests for your Xcode project using XCTest.
Posts under XCTest tag
82 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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
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.
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)?
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
Xcode
XCTest
Testing
Swift Testing
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)
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.
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
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.
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
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'
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
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?
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.
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!
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)
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.
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.
The launch argument -com.apple.TipKit.HideAllTips 1 does not work if it is defined in xctestplan arguments passed on launch.
I tested it with the apple provided example app, where I created simple UI test and added xctestplan with launch argument -com.apple.TipKit.HideAllTips 1.
The app does not hide the tips when it is running the UI Tests.
Is there any solution that works?
Thanks for reply.
Hello,
I'm unable to run any test cases in Xcode 16 with the iOS 18 simulator.
Steps to Reproduce:
Create a new iOS project in Xcode 16 using the default iOS app template with the testing option checked.
Run any test or UI test case by clicking the "Play" icon in the Test navigator.
Xcode gets stuck at the "Testing" state indefinitely.
Environment:
macOS 15 beta 8
Xcode 16 beta 6
iOS 18 beta 7 simulator
Hi!
I must be missing something. I am creating a MacOS dynamic library using Xcode. I have created the library as follows:
File->New Project then choose macOS 'Library' in Frameworks and Libraries.
I give the Product Name "TestLib".
Framework: STL (C++ Library)
Type: Dynamic
This creates a default library project, with one exported class 'TestLib'. There's a method "HelloWorld". And this suffices for my issue.
To be able to test my dynamic library, I want to use an XCtest target.
So in the project settings, I select '+', and add a 'Unit Testing Bundle':
Product name: TestLibTests
Language: Swift
Testing System: XCTest
Project: TestLib
Target to be tested: TestLib
I press finish, and my test target is created.
Now, I think I need to have a module map. So I Add New File From Template', and choose 'Module Map'. A 'module.modulemap' is created. In the module map file, I name the module 'TestLib', and header 'TestLib.h'.
So far, everything makes sense, and no errors. But here it comes...
When I want to make a testcase, I need to import the module. I first built the dylib library, to make sure it's built without errors and exists.
Then I switch to the TestLibTests target and want to write my first test. Simply creating an object from the TestLib class. For that, I have to import the module, so I write 'import TestLib' after the 'import XCTest' at the top.
And here is where I'm stuck. No matter what I do, Xcode just gives me the error 'No such module TestLib'.
This should just work, right? I should be able to unit test my library. I have spent 2 days reading the internet and trying many suggestions, but I just can't get it to work.
I am currently working with Xcode 26 beta. But I tried with Xcode 16.4 and that has the same issue.
What am I missing?