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

Posts under XCTest tag

145 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

No screenshot files in XCResult files using Xcode 16.1
Hello, I am using Xcode 16.1 (16B40) on MacOS Sequoia 15.1.0 using a Macbook pro M1 Max I am developing an app for iOS 17 and 18 using SwiftUI I created UITests to take the screenshots for the appStore on the simulator The tests run well and all of them are succeded The problem appears when I try to get the screenshot files from the xcresult files after the test. There is not any screenshot inside it. I found a data folder and a Info.plist file. In the data folder there are a lot of files with this pattern data.03zD4C6IGFFthK14NwA8mNvcwFHT16g6Tl40Tl1YmBC1bNh6d0YIcnWKyUaQPDXoa8fYo6C3Xcv8xvMtE3_NEXA== and other files with this pattern refs.03zD4C6IGFFthK14NwA8mNvcwFHT16g6Tl40Tl1YmBC1bNh6d0YIcnWKyUaQPDXoa8fYo6C3Xcv8xvMtE3_NEXA== Ok, I tryed to use fastlane to automatize the screenshots but the problem is still present. The xcresult files have not any png file. I had no problems doing this action (getting screenshots from a xcresult file) in previous versions of MacOS and Xcode in my current machine. I just updated my machine to MacOS Sequoia 15.1.1 and the problem is still present Honestly I don't know how to fix this situation. With Xcode 15 I had not any problem with that but I am not sure if Xcode 16.0 was runing without problems because I didn't need to use this functionality in those months Here is my code for a UITest: import XCTest final class ScreenshotsUITests: XCTestCase { let app = XCUIApplication() let device = "iPhone16" override func setUpWithError() throws { continueAfterFailure = true } override func tearDownWithError() throws {} @MainActor func testEnglishScreens() throws { let lang = "en" app.launchArguments.append("UITestMode") app.launchArguments += ["-AppleLanguages", "(en)"] app.launchArguments += ["-AppleLocale", "en_US"] app.launch() executeTestsForMenus(lang: lang, backLabel: "Back") executeTestForMatch(lang: lang) } @MainActor func testSpanishScreens() throws { let lang = "es" app.launchArguments.append("UITestMode") app.launchArguments += ["-AppleLanguages", "(es)"] app.launchArguments += ["-AppleLocale", "es_ES"] app.launch() executeTestsForMenus(lang: lang, backLabel: "Atrás") executeTestForMatch(lang: lang) } private func executeTestForMatch(lang: String) { let startButton = app.buttons["start-button"] startButton.tap() let key4 = app.buttons["key-4"] XCTAssertTrue(key4.waitForExistence(timeout: 30), "Key 4 in match screen is not found") key4.tap() let key2 = app.buttons["key-2"] XCTAssertTrue(key2.exists, "Key 2 in match screen is not found") key2.tap() makeScreenShot("playing", lang: lang) let closeButton = app.buttons["close-button"] XCTAssertTrue(closeButton.exists, "Close button in match screen is not found") closeButton.tap() } private func executeTestsForMenus(lang: String, backLabel: String) { let mainHeader = app.staticTexts["Math match"] XCTAssertTrue(mainHeader.exists, "Header in main screen is not found") makeScreenShot("mainMenu", lang: lang) let settingsButton = app.buttons["settings-button"] XCTAssertTrue(settingsButton.exists, "Settings button in main screen is not found") settingsButton.tap() makeScreenShot("Settings", lang: lang) let backButton = app.buttons[backLabel] XCTAssertTrue(backButton.exists, "Back button in match screen is not found") backButton.tap() let helpButton = app.buttons["help-button"] XCTAssertTrue(helpButton.exists, "Help button in main screen is not found") helpButton.tap() makeScreenShot("Help", lang: lang) backButton.tap() let scoreButton = app.buttons["score-button"] XCTAssertTrue(scoreButton.exists, "Scores button in main screen is not found") scoreButton.tap() makeScreenShot("Scores", lang: lang) backButton.tap() let playButton = app.buttons["play-button"] XCTAssertTrue(playButton.exists, "Play button in main screen is not found") playButton.tap() makeScreenShot("matchBuilder", lang: lang) let startButton = app.buttons["start-button"] XCTAssertTrue(startButton.exists, "Start button in match builder screen is not found") } private func makeScreenShot(_ name: String, lang: String) { takeScreenshot(app, named: "\(lang)-\(name)-\(device)") } } import XCTest extension XCTestCase { func takeScreenshot(_ app: XCUIApplication, named name: String, fullScreen: Bool = false) { let screenshot: XCUIScreenshot if fullScreen { screenshot = app.windows.firstMatch.screenshot() } else { screenshot = XCUIScreen.main.screenshot() } let screenshotAttachment = XCTAttachment( uniformTypeIdentifier: "public.png", name: "screenshot-\(name).png", payload: screenshot.pngRepresentation, userInfo: nil) screenshotAttachment.lifetime = .keepAlways add(screenshotAttachment) } } and here is the content of my testplan file: { "configurations" : [ { "id" : "35BC7C0B-9A5A-4027-9F30-36958C4C1AAF", "name" : "Test Scheme Action", "options" : { "preferredScreenCaptureFormat" : "screenshot", "testExecutionOrdering" : "random", "uiTestingScreenshotsLifetime" : "keepAlways", "userAttachmentLifetime" : "keepAlways" } } ], "defaultOptions" : { "targetForVariableExpansion" : { "containerPath" : "container:myAppProject.xcodeproj", "identifier" : "B27D1B022CA00314001A259B", "name" : "MyAppProject" } }, "testTargets" : [ { "parallelizable" : true, "target" : { "containerPath" : "container:MyAppProject.xcodeproj", "identifier" : "B27D1B122CA00315001A259B", "name" : "MyAppProjectTests" } }, { "parallelizable" : true, "target" : { "containerPath" : "container:MyAppProject.xcodeproj", "identifier" : "B27D1B1C2CA00315001A259B", "name" : "MyAppProjectUITests" } } ], "version" : 1 } I made tests with old projects in my machine and those projects have the same problem with screenshot files in the xcresult bundles I don't know if the problem is in my machine, my Xcode, MacOS or other ting. I don't know how to fix this problem Please, can anyone help me? Thanks in advance
0
0
33
21h
Unable to inspect SwiftUI view embedded inside UITableView
We have been trying to migrate screens that were developed using UITool Kit to SwiftUI. In the process we have some screens that have SwiftUI embedded inside the UITool kit view. Our developers have defined accessibility ids for all elements in these views and these are inspectable using the native iOS xcode inspector. However when i try inspecting it with the appium inspector i get an empty list with no elements in the hierarchy tree. Attaching a screenshot of the element when inspecting through the native xcode accessibility inspector, Attaching a screenshot of the same screen when inspected through the appium inspector, Also tried printing the XCTest UI dump using appium method, `driver().executeScript("mobile:source", Map.ofEntries(Map.entry("format","description"))) The UI tree i get is the same that i get when inspecting through the appium inspector. Requesting support from the Apple team based on this ticket, [https://github.com/appium/appium/issues/20759)
0
0
59
22h
Not seeing signposts when profiling a unit test (Xcode 16.1)
While I was recently profiling some code from a Swift library, I noticed that XCTest added in signposts for the measurement tests, which I found really helpful to "home in" on the code I wanted to profile digging around in the stack trace. I tried to add my own signposts to provide just a bit of my own markers in there, but while it compiles and profiles equivalently, the signposts just aren't showing up. This is with Xcode 16.1, macOS Sequoia (15.1) and a swift library, using XCTest and profiling within one of the unit tests. Is there something in this sequence that doesn't allow the library to set up signposts and have instruments collect them? The flow I'm using: import os let subsystem = "MyLibrary" class MyClass { let logger: Logger = .init(subsystem: subsystem, category: "fastloop") let signposter: OSSignposter init() { signposter = OSSignposter(logger: logger) } func goFast() { let signpostId = signposter.makeSignpostID() let state = signposter.beginInterval("tick", id: signpostId) // ... do a bunch of work here - all synchronous signposter.endInterval("tick", state) } } Is there something I'm doing incorrectly in using this API, or not enabling to allow those signposts to be collected by the profiler? I do see the signposts that XCTests injects into the system, just not any of the ones I'm creating.
1
0
110
2d
XCUITest Screen Recording
In WWDC23: Fix failures faster with Xcode test reports, the presenter showed off an Xcode feature called Automation Explorer, that allows playback of a screen recording corresponding to an XCUITest. For the life of me, I have not been able to find out how to enable/use this feature in Xcode 16. I am using Test Plans and have set the UI Testing configuration settings for Automatic Screen Capture to On, and keep all and Preferred Capture Format to Video, but am not seeing any screen recordings being produced after running the tests. Am I doing something wrong?
1
0
115
2d
Run identical UI/Unit tests on different build targets
I have different versions of my iOS App (written in SwiftUI). The app on the store, the App Clip, and one or two next version apps not yet released (e.g. A/B comparison). All good. But now I've started creating UI and Unit tests and I'm confused about how to get this working. Each build target has its own scheme. And in that scheme I have a Test plan for that target. E.g. The App Clip scheme has an App Clip test plan. Since all the app variants are very similar, I only have one set of unit tests and one set of UI tests so each test plan includes the same unit test target and the UI test target. Problem: When I selected a scheme (e.g. for the App Clip) and ran the tests, it turned out that all the tests ran for another build target, not the target of the scheme. I think this might be because within the definition of the test target there's a field specifying the host application. I.e. the build target. Question: How can I set up my project so that the test plan uses the relevant target build? Or do I have to duplicate all the test targets (one for each target)? Or do I have to manually change each test target before running it for a particular build target?
1
0
114
5d
Crash calling UIHostingController from a Swift Package
Hello team, We recently found a EXC_BAD_ACCESS crash when using UIHostingControllers on a SPM local Package in our application. This is happening from time to time when we run the app on simulators using Debug configurations. Also, this issue is consistent when we run application tests, there is something weird that we found after making a research... If we disable app test target and only keep packages tests, the crash is not happening, but as soon as we re-enable the app test target from the test suite the crash returns. This is the full error message: Thread 1: EXC_BAD_ACCESS (code=1, address=0xbad4017) A bad access to memory terminated the process. Is this s known issue? We've been performing explorations for some days and couldn't find any real solution for this. A basic call on UIHostingController inside of a SPM local Package is enough to make the app crash, nothing custom being done: UIHostingController(rootView: MyView())
2
0
160
2w
macOS Sequoia doesn't respect Full Disk Access for UITests-Runner
We develop and test App for macOS. We start to see system alert - "UlTests-Runner" would like to access data from other apps on each UITest run. Our test suite does cleanup of files generated by App so we need access outside of UITests-Runner sandbox. We enabled Full Disk Access for UITests-Runner at Settings -> Privacy & Security -> Full Disk Access but unfortunately still see this alert. Is there any way to permanently remove/hide this alert or remove sandbox for 'UITests-Runner' since we want to run tests on CI and having this alert is not an option? Note: everything works fine on previous versions of macOS. Environment: macOS - 15.1 (24B83) Xcode - Version 16.1 (16B40)
0
1
131
2w
iOS simulator freezes on macOS Sequoia during test execution
Hello! 👋 We are seeing a bug on macOS Sequoia related to the test running. When attempting to run tests, the iOS simulator becomes stuck indefinitely. This can occur whether we run tests for a specific module, all unit tests, or even a single test. We narrowed down the issue and is due to the OS failing to copy some named pipes (FIFO). For example: db.realm.note db.realm.management/access_control.new_commit.cv db.realm.management/access_control.pick_writer.cv We saw in the CoreSimulator log file the following error: NSCocoaErrorDomain Code=512 ""access_control.new_commit.cv" couldn't be copied The copy fails and then a new clone of the simulator is created retrying the process. And this goes on and on. What is happening? When running the tests for the iOS app on the simulator, under the hood, the OS tries to clone the simulator device. A list of folders is created, including one Shared/AppGroup. Under the AppGroup folder, the list of multiple UDIDs corresponds to the specific App Group containers created for individual app targets or extensions that are sharing data within that App Group. One of these folders contains the Realm DB files. There are a few files called named pipes which are invisible in Finder (even if you have hidden files to true). You need to list them with ls -l. So, when we select the test target and run the tests, the OS clones the permanent simulator and copies all files from its folders. All files are being copied except those pipes. When the OS attempts to copy the pipes, the operation fails with the error Code=512. Reproduction Steps Run the iOS app on a simulator (e.g. iPhone SE 3rd gen. with iOS 18.1). Quit Xcode and the iOS simulator. Reopen Xcode. Select a test target to run. Select the same simulator you previously ran the iOS app. Run the tests (CMD + U). The simulator is now stuck. Are there any workarounds available? Yes. We found that running the tests works if we first “Erase All Content and Settings” from the simulator. Another workaround is to remove all simulators and reinstall the iOS runtimes. This prevents the issue for a longer period (almost a full day), but eventually, the problem reoccurs. Alternatively, we can delete the named pipes from the App Groups directory before running the tests. Have we tried to give full disk permissions? Yes, we tried to give full disk permissions to a lot of things (Xcode, simulator, file paths, directories, etc.) but with no luck. We still get the same error. Is the issue happening on a specific version of Xcode? No, it happens for multiple Xcode versions: Xcode 15.4 Xcode 16.0 Xcode 16.1 Is the issue happening on a specific macOS Sequoia version? No, it happens on multiple macOS Sequoia versions: 15.0 Beta 8 15.0 RC 15.0 15.1 Stacktrace Oct 29 17:41:18 CoreSimulatorService[14079] <Error>: New device is stuck in creation state, deleting: Clone 712 of iPhone SE (3rd generation) (58D6DED6-2C55-4E7C-BBB4-E0D661DC41A1, iOS 18.1, Creating) Oct 29 17:41:20 CoreSimulatorService[14079] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.} Oct 29 17:41:20 com.apple.dt.Xcode[90147] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.} Oct 29 17:41:30 CoreSimulatorService[14079] <Warning>: Device 6C270BDB-2945-42B5-A985-884F93BFD3E1 encountered in creation state at launch. The device will be re-created. Oct 29 17:41:38 CoreSimulatorService[14079] <Error>: Failed to clone the device data path, error = Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=( Copy ), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffa490 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}} Oct 29 17:41:38 CoreSimulatorService[14079] <Error>: Failed to re-create device that was encountered in the creation state (Clone 713 of iPhone SE (3rd generation) (6C270BDB-2945-42B5-A985-884F93BFD3E1, iOS 18.1, Creating)): Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=( Copy ), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffa490 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}} Oct 29 17:41:40 CoreSimulatorService[14079] <Error>: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Device was allocated but was stuck in creation state. Check CoreSimulator.log for more information.} Oct 29 17:41:50 CoreSimulatorService[14079] <Warning>: Device C6DEBFBB-6EFA-4E4C-B51B-9DDA08AF9BDB encountered in creation state at launch. The device will be re-created. Oct 29 17:41:55 CoreSimulatorService[14079] <Error>: Failed to clone the device data path, error = Error Domain=NSCocoaErrorDomain Code=512 "“access_control.new_commit.cv” couldn’t be copied to “db.realm.management”." UserInfo={NSSourceFilePathErrorKey=[...]/db.realm.management/access_control.new_commit.cv, NSUserStringVariant=( Copy ), NSDestinationFilePath=[...]/db.realm.management/access_control.new_commit.cv, NSUnderlyingError=0x600000ffb000 {Error Domain=NSPOSIXErrorDomain Code=45 "Operation not supported"}} Oct 29 17:42:06 CoreSimulatorService[14079] <Warning>: Device 032BAE7E-E345-48F2-86EB-4DF1AD4D5291 encountered in creation state at launch. The device will be re-created.
0
0
181
2w
How to correctly resolve URL bookmarks for use in Simulator UI tests?
To make UI testing easier and faster, I usually create URL bookmarks during normal app usage in the Simulator so that they can be instantly resolved on app launch during UI tests. For example, one of my apps allows browsing selected folders and stores bookmarks so they can be quickly opened again on following app launches, and instead of selecting the test folder each time at the beginning of the UI test, I select it once during normal app usage so that it's available immediately during the UI test. This usually works fine, but every now and then the UI tests fail because the tested app isn't able to resolve the stored bookmark. I don't know why this happens, but usually opening and closing the app again in the Simulator and re-running the UI tests solves the issue. The problem now is that I've just tried to setup some new UI tests for Apple Vision Pro Simulator and I'm never able to resolve bookmarks. So I created a sample project that reproduces the issue, and curiously enough the bookmarks don't even resolve when using an iPad Simulator (which usually works fine with my regular UI tests). What am I doing wrong? This can be reproduced with a default iOS project, embedding the default storyboard view controller in a navigation view controller, and this code: import UIKit class ViewController: UIViewController, UIDocumentPickerDelegate { override func viewDidLoad() { navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .add, primaryAction: UIAction(handler: { _ in let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder]) picker.delegate = self self.present(picker, animated: true) })) if let bookmark = UserDefaults.standard.data(forKey: "bookmark") { readBookmark(bookmark) } } func readBookmark(_ bookmark: Data) { do { let label = UILabel(frame: CGRect(x: 100, y: 100, width: 600, height: 100)) label.numberOfLines = 0 var stale = false let url = try URL(resolvingBookmarkData: bookmark, bookmarkDataIsStale: &stale) if !url.startAccessingSecurityScopedResource() { fatalError() } label.text = url.path view.addSubview(label) } catch { fatalError(error.localizedDescription) } } func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { do { let url = urls[0] if !url.startAccessingSecurityScopedResource() { fatalError() } let bookmark = try url.bookmarkData() UserDefaults.standard.set(bookmark, forKey: "bookmark") readBookmark(bookmark) } catch { fatalError(error.localizedDescription) } } } And a default UI test, which always crashes because of the fatalError() in the catch clause of readBookmark(_:): final class problemUITests: XCTestCase { @MainActor func testExample() throws { let app = XCUIApplication() app.launch() } }
0
0
121
3w
Xcode UI test always fails to tap close button in font picker navigation bar
I'm trying to close the UIFontPickerViewController in a UI test by tapping the close button in the navigation bar. In a default iOS app, I embed the default storyboard view controller in a navigation view controller, then in code I open the font picker like this: class ViewController: UIViewController, UIFontPickerViewControllerDelegate { override func viewDidAppear(_ animated: Bool) { let picker = UIFontPickerViewController(configuration: .init()) picker.delegate = self self.present(picker, animated: true) } func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController) { } } And the UI test looks like this: final class problemUITests: XCTestCase { @MainActor func testExample() throws { let app = XCUIApplication() app.launch() sleep(2) let button = app.navigationBars.element(boundBy: 1).buttons.element(boundBy: 0) print(button.debugDescription) XCTAssert(button.waitForExistence(timeout: 2)) button.tap() } } When running the UI test, the XCTAssert always fails and the button.tap() also fails with an error message Failed to tap "chiudi" Button: No matches found for Element at index 1 from input {( NavigationBar )} "chiudi" means "close" in Italian, my macOS system language. It sounds to me like I correctly get the close button, but the messages Xcode prints make no sense to me. It's particularly confusing given that the output of the print statement shows that the button is there, but somehow fails to be tapped: Attributes: Button, 0x104f44660, {{701.0, 320.0}, {43.0, 44.0}}, label: 'chiudi' Element subtree: →Button, 0x104f44660, {{701.0, 320.0}, {43.0, 44.0}}, label: 'chiudi' Image, 0x104f44780, {{709.0, 327.5}, {30.0, 30.0}}, identifier: 'UICloseButtonBackground' Path to element: →Application, 0x104f35940, pid: 29803, label: 'problem' ↳Window (Main), 0x104f376a0, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f42e10, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f43100, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f43220, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f43340, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f43460, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f43580, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f436a0, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f437c0, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f438e0, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f43a00, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f43b20, {{0.0, 0.0}, {1032.0, 1376.0}} ↳Other, 0x104f43c40, {{276.0, 314.0}, {480.0, 748.0}} ↳Other, 0x104f43e80, {{276.0, 314.0}, {480.0, 748.0}} ↳Other, 0x104f43fa0, {{276.0, 314.0}, {480.0, 748.0}} ↳Other, 0x104f440c0, {{276.0, 314.0}, {480.0, 748.0}} ↳Other, 0x104f441e0, {{276.0, 314.0}, {480.0, 748.0}} ↳Other, 0x104f44300, {{276.0, 314.0}, {480.0, 748.0}} ↳NavigationBar, 0x104f44420, {{276.0, 314.0}, {480.0, 108.0}}, identifier: 'Scegli font' ↳Button, 0x104f44660, {{701.0, 320.0}, {43.0, 44.0}}, label: 'chiudi' Query chain: →Find: Target Application 'org.desairem.problem' Output: { Application, 0x104f781b0, pid: 29803, label: 'problem' } ↪︎Find: Descendants matching type NavigationBar Output: { NavigationBar, 0x10607c0d0, {{0.0, 24.0}, {1032.0, 50.0}}, identifier: 'UIFontPickerView' NavigationBar, 0x10607dab0, {{276.0, 314.0}, {480.0, 108.0}}, identifier: 'Scegli font' } ↪︎Find: Element at index 1 Output: { NavigationBar, 0x1064693a0, {{276.0, 314.0}, {480.0, 108.0}}, identifier: 'Scegli font' } ↪︎Find: Descendants matching type Button Output: { Button, 0x104f714a0, {{701.0, 320.0}, {43.0, 44.0}}, label: 'chiudi' Button, 0x104f71800, {{711.0, 378.0}, {17.0, 22.0}}, identifier: 'Dictate', label: 'Avvia dettatura' } ↪︎Find: Element at index 0 Output: { Button, 0x104f5d5e0, {{701.0, 320.0}, {43.0, 44.0}}, label: 'chiudi' }
0
0
114
3w
How to simulate match face ID / touch ID on XCUITest
How can I test biometric on UI Tests in Swift / iOS 18? This code not working. + (void)successfulAuthentication { notify_post("com.apple.BiometricKit_Sim.fingerTouch.match"); notify_post("com.apple.BiometricKit_Sim.pearl.match"); } + (void)unsuccessfulAuthentication { notify_post("com.apple.BiometricKit_Sim.fingerTouch.nomatch"); notify_post("com.apple.BiometricKit_Sim.pearl.nomatch"); }
0
0
157
3w
Unable to run test in devices with MDM Profiles
Requirement : We wanted to run UI Automation using xcuitest in devices with MDM profiles. Steps : We have created a test target for our app and signed with MDM profile (in-house) Generated app and testbundle-Runner along with xctestrun files using “xcodebuild build-for-testing -scheme “App-TestRelease" -configuration “Release” -derivedDataPath "${CURDIR}/derivedData" -workspace "${PROJECT_NAME}.xcworkspace" -sdk iphoneos” Tried running “xcodebuild test-without-building -destination platform=iOS,id=000842883-**** -xctestrun App-TestRelease_iphoneos17.5-arm64.xctestrun -derivedDataPath /derived/“ Facing below issues xcodebuild[35481:3588352] IDELaunchReport: e2934a094f300d40:e2934a094f300d40: Finished with error: Unable to launch com.org.mdm.XCTest.xctrunner Domain: com.apple.platform.iphoneos Code: -12 User Info: { IDERunOperationFailingWorker = IDELaunchiPhoneLauncher; } -- Request to launch com.org.mdm.XCTest.xctrunner failed. Domain: com.apple.dt.deviceprocesscontrolservice Code: 2 Failure Reason: The request to open "com.org.mdm.XCTest.xctrunner" failed. : Failed to launch process with bundle identifier 'com.org.mdm.XCTest.xctrunner'. -- The request to open "com.org.mdm.XCTest.xctrunner" failed. Domain: FBSOpenApplicationServiceErrorDomain Code: 1 Failure Reason: The request was denied by service delegate (SBMainWorkspace) for reason: Security ("Unable to launch com.org.mdm.XCTest.xctrunner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user"). User Info: { BSErrorCodeDescription = RequestDenied; FBSOpenApplicationRequestID = 0x9f9; } -- The operation couldn’t be completed. Unable to launch com.org.mdm.XCTest.xctrunner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. Domain: FBSOpenApplicationErrorDomain Code: 3 Failure Reason: Unable to launch com.org.mdm.XCTest.xctrunner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. User Info: { BSErrorCodeDescription = Security; }
1
0
212
3w
Are SwiftUI Text views with empty strings optimized out in iOS 18?
A UI test case that checks for the existence of a SwiftUI Text element initialized with an empty string previously reliably passed in iOS 17. In iOS 18 the assertion reliably fails. I searched the iOS 18 developer release notes for anything possibly related to this but didn't find much. I'd like to point to a conclusive change in iOS handling before changing the test permantently. Can anyone confirm that this is indeed a change in iOS 18?
0
3
164
4w
Unit Test Execution in Xcode Cloud Too Slow Since Xcode 16 Update
Hello Developers, I regularly use Xcode Cloud to run unit tests, but since the release of Xcode 16, the testing process has become significantly slower. I am seeking advice on how to improve the situation. [ Details ] With Xcode 15.4, unit tests took about 1 hour to complete. However, since upgrading to Xcode 16, the tests have not finished even after 2 hours. The blog post linked below also mentions significant overhead in running unit tests on Xcode Cloud, even with Xcode 15.4: https://dwango.github.io/articles/2024-07_nicoiphone_xcode_cloud/#%E3%83%86%E3%82%B9%E3%83%88%E5%AE%9F%E8%A1%8C%E6%99%82%E9%96%93%E3%81%8C%E5%A2%97%E5%8A%A0%E3%81%97%E3%81%A6%E3%81%97%E3%81%BE%E3%81%86%E5%95%8F%E9%A1%8C According to the blog, while reviewing the xcodebuild-test-without-building.log, it was observed that the time from start to finish was about 4 minutes. However, the overall “Run xcodebuild test-without-building” process took 23 minutes, with around 20 minutes of apparent idle time. It seems that the idle time has increased even further with Xcode 16, resulting in more than twice the testing time. [ Question/Request ] Is there any way to reduce the overhead when running unit tests on Xcode Cloud, especially with the increased overhead in Xcode 16? Any advice or solutions for improving the performance would be greatly appreciated. Best regards,
2
2
393
Oct ’24
Setting tint for widget snapshot tests iOS 18
We have widget snapshot tests using XCTest as shown below: func testHomeWidgetView() { let widgetView = HomeWidgetView( state: .done, text: "All done!" ).frame(width: 170, height: 170) assertSnapshot(matching: widgetView, as: .image) } } Is it possible to apply a tint to the widgets in snapshot tests like a user can from their home screen in iOS 18? We'd like to capture snapshots of our widget while tinted via the home screen.
1
2
190
3w
Xcode "Build For Testing" always returning x86_64 architecture for code coverage purposes
When using Xcode's "Build for Testing", I have noticed the resulting MyApp.xctestrun file has an array of CodeCoverageBuildableInfos. This array has all of our built targets. They all have an Architectures array property. For all of our targets this is set to x86_64 when we build for Any iOS Simulator. This is irrespective of what we have "ARCHS" and "ONLY_ACTIVE_ARCH" set to (in our case we only want arm64). We do have a number of local swift packages defined, each with their own test targets. We are using a test plan for these tests. This is causing issues when processing the resulting xcresult file since it is complaining that it can't find objects for the correct architecture when calculating code coverage. No object file for requested architecture No coverage data found. (Underlying Error: No object file for requested architecture)
0
0
193
Oct ’24