In V 0.1 of my app, I went with a simple option for a piece of business logic in my app.
I then changed something else that caused my simplified business logic to now crash the app at startup.
Excellent, a chance to use Test. Driven Design to replace my flawed business logic.
So I wrote my first test TDD test, but when I tried to run the test... It doesn't run because running the test target seems to start by actually running my full app (which as I described in chapter 1 is currently crashing)
Have I configured something incorrectly? or is it normal that when I attempt to run a single test, step 1 is running the full app?
(note: it is very easy for me to disable/avoid the business logic causing my crash. This question is more about my lack of understanding of what it means to run a test target.)
thanks in advance for any and all responses.
Mike
Testing
RSS for tagDetect issues like logic failures, UI problems, and performance regressions by running tests on your app.
Posts under Testing tag
106 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hello everyone, I looked at various methods how to Unit/UITest SwiftData but I couldn't find something simple. Is it even possible to test SwiftData? Does someone found a solution for that?
Steps to reproduce:
Install & Launch App
When push notifications are registered, the push notification token received is a "production" push notification token rather than a "development" push notification token.
We are trying to test on the sandbox environment with development push notification tokens, however the apn-environment for all builds we release via TestFlight are being set to "production". We wish to distribute builds via TestFlight with apn-environment set to "development".
At the moment we have only found one way to run the app with apn-environment set to "development" which is to "Export" a Debug build, then manually install it on a device via iTunes on Windows machines. This method is not efficient or considered seamless enough for non-technical testers and stakeholders. They require a seamless way to receive Debug builds via TestFlight without resorting to other third-party platforms which allow us to manually upload the "Exported Debug build".
If anyone knows how to upload a "Debug" build to Testflight which will allow the user to receive a sandbox development push token with "apn-environment" set to development I would really appreciate it.
In order to test an iPhone app I am developing on my mac on an actual device, I connected my iPhone to my mac with a wired connection and installed the app, but got an error message saying “Uneble to verify app”.
I went to Settings -> General -> VPN and Device Management -> the app in question in ENTERPRISE APP -> Verify App -> Verify, but no matter how many times I tap on it, the status of the app remains “Not verified”.
If anyone has a solution to this problem, we would appreciate it if you could help us.
For our iOS inception e2e test, sometimes the test is blocked by the Mac pop-up window alert. The possible pop-up as follows:
Java Access Pop-up
Accessibility Pop-up
SystemProperty Pop-up
and so on......
In order to fetch the unexpected pop-up dialog window when executing e2e tests. I write a simple Apple script get_popup_windows.scpt as follows:
tell application "System Events"
set allProcesses to processes whose background only is false
-- Log the count of allProcesses
log "Number of processes found: " & (count of allProcesses)
set dialogInfos to {}
repeat with eachProcess in allProcesses
try
tell eachProcess
log "Process Name: " & (name of eachProcess as text)
set allWindows to (windows whose subrole is "AXStandardWindow" or subrole is "AXDialog")
log "Number of allWindows found: " & (count of allWindows)
repeat with eachWindow in allWindows
set uiElements to UI elements of eachWindow
log "eachWindow: " & (name of eachWindow as text)
set the end of dialogInfos to {title:(name of eachWindow as text), processName:(name of eachProcess as text)}
end repeat
end tell
end try
end repeat
end tell
return dialogInfos
However, when I execute the script: osascript get_popup_windows.scpt
The result as follows:
Number of processes found: 10
Process Name: Terminal
Number of allWindows found: 1
eachWindow: scripts — osascript get_popup_windows.scpt — 143×41
Process Name: Google Chrome
Number of allWindows found: 1
eachWindow: Gemini - Google Chrome - Will
Process Name: sublime_text
Number of allWindows found: 0
Process Name: Notes
Number of allWindows found: 0
Process Name: Music
Number of allWindows found: 0
Process Name: Finder
Number of allWindows found: 0
Process Name: app_mode_loader
Number of allWindows found: 0
Process Name: Simulator
Number of allWindows found: 0
Process Name: app_mode_loader
Number of allWindows found: 0
Process Name: Script Editor
Number of allWindows found: 0
title:scripts — osascript get_popup_windows.scpt — 143×41, processName:Terminal, title:Gemini - Google Chrome - Will, processName:Google Chrome
=> I cannot fetch the target pop-up window in the Mac desktop.
Please guide me if you have any suggestions, thanks.
In order to fetch the unexpected pop-up dialog window when executing e2e tests. For example:
I write a simple Apple script get_popup_windows.scpt as follows:
tell application "System Events"
tell process "SystemUIServer"
set securityAlertWindows to (every window whose subrole is "AXDialog")
set securityAlertTitles to {}
repeat with securityAlertWindow in securityAlertWindows
set securityAlertTitle to (securityAlertWindow's title as text)
set end of securityAlertTitles to securityAlertTitle
end repeat
end tell
end tell
return securityAlertTitles
However, when I execute osascript get_popup_windows.scpt
It returns empty even when there is a popup window in my mac.
Does anyone know the reason? Thanks for help.
Will
TL:DR
Can anyone provide guidance as to how to get the FileProvider testing API to work? It closes with no error and I have not been able to determine the issue despite careful attention to the documentation and signing. The Console logs seem to imply it is a Sandbox issue.
Hi,
Writing this as per suggested in the technical support section.
I am trying to create some tests that involve controlling the calls from MacOS to the corresponding "event" functions in the FileProvider (e.g. fetchContents()) using the FileProviderExtension test API provided by Apple.
I have thoroughly read the documentation (both online and within the API code) in order to get this to work. I have:
Added the com.apple.developer.fileprovider.testing-mode entitlement to both my Main App as well as my FileProviderExtension
Ensured my I have the correct account permissions, and provisioning profiles for my Main App as well as FileProviderExtension
Added the line domain.testingModes = [.alwaysEnabled, .interactive]
The issue: I found that setting the .interactive option in my domain.testingModes will result in my domain in Finder appearing to be stuck loading the root folder, and that my FileProviderExtension instance is being invalidated and closing in ~5s. It is reproducible. Is this a bug?
Some things I have noticed:
Attaching the debugger to the FileProviderExtension process results in no error. Additionally there is no error received when calling add(:domain).
I noticed through testing that the Main App appears to be required to have the com.apple.developer.fileprovider.testing-mode entitlement in order to run a FileProviderExtension with that same entitlement. Otherwise I would receive the error: Error Domain=NSCocoaErrorDomain Code=257 "The file couldn’t be opened because you don’t have permission to view it"
When trying to sign manually using a group Developer ID Application certificate as opposed to automatically with my Apple Development certificate Xcode presents the error "Main app provisioning profile" doesn't support the FileProvider Testing Mode capability." Despite this I can clearly see that is an enabled capability though the online Apple Developer portal under the Profiles section. Note that the only capabilities enabled when viewing the bundle identifiers of the Main App and FileProviderExtension are "FileProvider Testing Mode", "App Groups", and the (seemingly required) "In-App Purchases". I later realized that this was likely due to using the wrong type of provisioning profile so I generated and switched to MacOS Developer Profiles (as opposed to Distribution) and this error in XCode went away. However the above issue (FileProviderExtension instance being invalidated) persisted.
If I look at the Console I see various errors from when the extension is launched till it closes:
Sandbox: mdbulkimport(922) deny(1) mach-lookup com.apple.FileProvider
Sandbox: hiveDiskProvider(37981) deny(1) mach-lookup com.apple.mobile.keybagd.UserManager.xpc
[ERROR] Cannot query for providers. Error: NSError: Cocoa 4099 "<private>"
Error from beginMonitoringProviderDomainChangesWithHandler: Error Domain=NSCocoaErrorDomain Code=4099 UserInfo={NSDebugDescription=<private>}
Synchronizer coordinateReadingItemAtURL error: Error Domain=NSCocoaErrorDomain Code=3072
With the Development Provisioning Profiles I see a couple new errors:
From secinitd(App Sandbox) Failed to set LS data container personality info: <private>
A new error repeated a number of times from cfprefsd after trying to access some .plist files that don't appear to be on my system:
Error: Couldn't open parent path due to [2: No such file or directory]
Paths are: ~/Library/Containers/<extensionBundleID>/Data/Library/Preferences/ByHost/<extensionBundleID>.<ID>.plist
/Library/Managed Preferences/<username>/<extensionBundleID>.plist
Any help would be greatly appreciated :)
There was an error processing your request. Please try again later.
TestFlight
So I have a simple view for my SwiftUI application below:
import SwiftUI
struct ContentView: View {
var body: some View {
List {
ForEach(0..<4) { index in
RowView(index: index)
.accessibilityIdentifier("row")
}
}
}
}
struct RowView: View {
let index: Int
var body: some View {
HStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
Spacer()
ButtonView(index: index)
}
.padding()
}
}
struct ButtonView: View {
let index: Int
var body: some View {
VStack {
if index != 3 {
Button(action: {}, label: {
Text("Cancel")
})
.accessibilityIdentifier("cancel_button")
}
Button(action: {}, label: {
Text("Submit")
})
.accessibilityIdentifier("submit_button")
}
}
}
My goal is to reference each cancel and submit button per row for a UI Test, which I have tried doing so here:
let rowElements = app.tables.cells.matching(identifier: "row")
for i in 0..<rowElements.count {
let cancelButton = rowElements.element(boundBy: i).buttons["cancel_button"]
let submitButton = rowElements.element(boundBy: i).buttons["submit_button"]
XCTAssertTrue(cancelButton.exists, "Cancel button does not exist in row \(i)")
XCTAssertTrue(submitButton.exists, "Submit button does not exist in row \(i)")
}
Even with the identifiers set like this my tests fail and say it cannot find the buttons labeled as they are with their specific identifiers or the rows. What is the correct way to reference elements if they are in a list or table for UI Testing? I'm specifically trying to use accessibility Identifiers to make my life easy.
Hello everyone,
I'm programming my app and after a few days I opened and ran it on my iPhone. This app worked, but with one big problem. The problem is that the app doesn't show up in my settings and I don't know why. I didn't program/change anything.
Thanks for the advice
This code works when I run it in the iOS Simulator with iOS 17.0.1:
let passcodeInput = springboard.secureTextFields["Passcode field"]
_ = passcodeInput.waitForExistence(timeout: 10)
passcodeInput.tap()
However if I run it on the iOS Simulator with iOS 17.4 I get this error:
t = nans Checking existence of `"Passcode field" SecureTextField`
t = nans Capturing debug information
t = nans Requesting snapshot of accessibility hierarchy for app with pid 66943
t = nans Tap "Passcode field" SecureTextField
t = nans Wait for com.apple.springboard to idle
t = nans Find the "Passcode field" SecureTextField
t = nans Find the "Passcode field" SecureTextField (retry 1)
t = nans Find the "Passcode field" SecureTextField (retry 2)
t = nans Requesting snapshot of accessibility hierarchy for app with pid 66943
<unknown>:0: error: PRCheckUITests : Failed to tap "Passcode field" SecureTextField: No matches found for Descendants matching type SecureTextField from input {(
Application, pid: 66943, label: ' '
)}
Did the hardcoded string "Passcode field" change for iOS 17.4?
How can I access the passcode field through springboard in a test?
Hi everyone!
I'm developing a cross-platform application with Flutter framework and i found an anomaly that is not really answered on any forums or just I'm too blind to find that.
So if I'm making a debug build on a real device or I download a test app from TestFlight after the first launch the app pops a "*** would like to find and connect to devices on your local network" dialog.
I tested a few app from App Store (some of them was made with Flutter, for example Revolut) but non of them asks for the mentioned permission.
So my question is: the released apps in App Store also requires permission for connection to network (so the "*** would like to find and connect to devices on your local network" dialog shows up) and i need to set something in the configs to get the permission instantly or all apps in App Store got the permission by default.
Good morning.
I'm executing XCUitest tests on a real iPhone with iOS 17 and I'm receiving the following error:
2024-04-09 11:11:10.000 E HelloWorldE2EUITests-Runner(FrontBoardServices)[489] <Error>: Snapshot request 0x281f1c390 complete with error: <NSError: 0x281f373f0; domain: FBSSceneSnapshotErrorDomain; code: 4; "an unrelated condition or state was not satisfied"> {
NSLocalizedDescription = an error occurred during a scene snapshotting operation;
}
2024-04-09 11:11:10.000 E HelloWorldE2E(XCTTargetBootstrap)[490] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:12.000 E HelloWorldE2E(XCTTargetBootstrap)[491] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(FileProvider)[489] <Error>: [ERROR] Cannot query for providers. Error: NSError: Cocoa 257 "The file couldn\M-b\M^@\M^Yt be opened because you don\M-b\M^@\M^Yt have permission to view it."
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(FileProvider)[489] <Error>: [ERROR] received an error when listing providers, attempting again: Error Domain=NSCocoaErrorDomain Code=257 "The file couldn\M-b\M^@\M^Yt be opened because you don\M-b\M^@\M^Yt have permission to view it." (count: 3)
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(FileProvider)[489] <Error>: [ERROR] Cannot query for providers. Error: NSError: Cocoa 257 "The file couldn\M-b\M^@\M^Yt be opened because you don\M-b\M^@\M^Yt have permission to view it."
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(FileProvider)[489] <Error>: [ERROR] received an error when listing providers, attempting again: Error Domain=NSCocoaErrorDomain Code=257 "The file couldn\M-b\M^@\M^Yt be opened because you don\M-b\M^@\M^Yt have permission to view it." (count: 2)
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(FileProvider)[489] <Error>: [ERROR] Cannot query for providers. Error: NSError: Cocoa 257 "The file couldn\M-b\M^@\M^Yt be opened because you don\M-b\M^@\M^Yt have permission to view it."
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(FileProvider)[489] <Error>: [ERROR] received an error when listing providers, attempting again: Error Domain=NSCocoaErrorDomain Code=257 "The file couldn\M-b\M^@\M^Yt be opened because you don\M-b\M^@\M^Yt have permission to view it." (count: 1)
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(FileProvider)[489] <Error>: [ERROR] Cannot query for providers. Error: NSError: Cocoa 257 "The file couldn\M-b\M^@\M^Yt be opened because you don\M-b\M^@\M^Yt have permission to view it."
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(FileProvider)[489] <Error>: [ERROR] can't get the list of providers: NSError: Cocoa 257 "The file couldn\M-b\M^@\M^Yt be opened because you don\M-b\M^@\M^Yt have permission to view it."
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(CoreMediaIO)[489] <Error>: CMIOExtensionDiscoverySession.m:244:-[CMIOExtensionDiscoverySession setUpRegistration]_block_invoke Error received 3
2024-04-09 11:11:13.000 E HelloWorldE2EUITests-Runner(CoreFoundation)[489] <Error>: Not updating lastKnownShmemState in CFPrefsPlistSource<0x28231aac0> (Domain: com.apple.cameracapture.volatile, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes): 0 -> 16
2024-04-09 11:11:15.000 E HelloWorldE2E(AXRuntime)[491] <Error>: Unknown client: HelloWorldE2E
2024-04-09 11:11:26.000 E HelloWorldE2E(XCTTargetBootstrap)[494] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:29.000 E HelloWorldE2E(AXRuntime)[494] <Error>: Unknown client: HelloWorldE2E
2024-04-09 11:11:40.000 E HelloWorldE2E(XCTTargetBootstrap)[495] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:42.000 E HelloWorldE2E(AXRuntime)[495] <Error>: Unknown client: HelloWorldE2E
2024-04-09 11:11:44.000 E HelloWorldE2EUITests-Runner(UIKitCore)[489] <Error>: Background Task 3 ("Called by UIKitCore, from <redacted>"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
2024-04-09 11:11:46.000 E HelloWorldE2E(XCTTargetBootstrap)[497] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:48.000 E HelloWorldE2E(XCTTargetBootstrap)[498] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:51.000 E HelloWorldE2E(XCTTargetBootstrap)[500] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:54.000 E HelloWorldE2E(XCTTargetBootstrap)[501] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:56.000 E HelloWorldE2E(XCTTargetBootstrap)[502] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:11:58.000 E HelloWorldE2E(XCTTargetBootstrap)[503] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:12:01.000 E HelloWorldE2E(XCTTargetBootstrap)[504] <Error>: Error loading automation support library: Error Domain=com.apple.dt.xctest.error Code=1 UserInfo={NSLocalizedDescription=<private>}
2024-04-09 11:12:03.000 E HelloWorldE2E(AXRuntime)[504] <Error>: Unknown client: HelloWorldE2E
2024-04-09 11:12:29.000 E HelloWorldE2EUITests-Runner(XCTestCore)[489] <Error>: Exiting due to IDE disconnection.
I'm not understanding the error because this only happens on iOS 17, the same tests on iOS 16 is working just fine. Also, the log seems to make reference to two things:
Error on Snapshot request. Which is strange because I'm not making any snapshot on the tests.
Errors with the loading of this: Error loading automation support library: Error Domain=com.apple.dt.xctest.error. I'm confused here because I don't know where to start to begin to look for solve this.
New Apple Developer here,
I've built my first iOS app in Xcode and wants to get it onto some friends' iPhones to do some external testing and give me some feedback. I've read the Apple Developer documentation on how to use TestFlight, but it's not understandable since step 1 is entering information about the app in App Store Connect and step 2 is uploading the app to App Store Connect?
Can someone please write some easy step-by-step directions on how to get an iOS app from Xcode onto external testers' iPhones for a first-timer in 2024?
Thank you so much!
I have had an app on the apps store for about 4 years. The app uses an API to retrieve some data and displays/manipulates it. The app works for the vast majority of users however, for around 0.01% of users, the first time they open the app after downloading it, the API fails and reports that it cannot retrieve data (it exits elegantly but does not crash). They cannot get the app to work and I have to issue a refund.
I cannot repeat the error on simulator or on my test iPhone (13). There is no consistency on IOS or phone model reported. I am guessing that there is some form of configuration that cause the app to fail to retrieve the data.
I don't even know where to start to identify the problem. Can anyone point me to some documentation or provide advice as to how I can capture, analyse and fix these rare failures.
Thanks
Since couple of weeks ago (probably after I've updated my macbook to Sonoma 14.3.1) my Xcode cannot load unit test.
When opening Test Navigator all I see is: Loading Tests... and it stays forever in that state.
This is completely new project and this is crazy. Only way I can start testing is if I use CMD+U to run all the tests which is my company's project take a lot of time.
Also there's no option to click on test-diamond-shaped button to run individual tests. Also tried checking "Test Plans" but I have infinite progress views:
Anyone has any idea how to fix this?
I tried to remove Derived Data, to reinstall Xcode (and different versions), did "git clean -fxd" nothing helped. Also some function like: "Rename", "Edit all in scope" stopped working as well.
Hello world, I'm doing unit testing with Swift. I need to create a test for the registration process of an application. When I register, a confirmation link is sent to the specified email. How can I create a test that allows me to access the email and click on the link to confirm the registration?
Hi,
We're currently developing a PWA for our company - with Vue 3 and Quasar - and we have added it into the App Store (but in testing only, for now).
We have multiple problems but the worst is the following one: it seems that the app doesn't want to open external links with "window.open()" JS method. Instead it shows a screen with a progress bar and a crossed-out Wi-Fi icon.
It shows this for a few seconds then once the progress bar is completly filled it goes back to the previous page where it triggered. Needless to say that the wireless is connected (see the status icons at the top).
We have the same behavior when we try to download a PDF created as a BLOB file with some JS code.
I don't have an iPhone to test so maybe you have a good idea about this ?
Kind regards,
V.
Hello!
Since Xcode 15 came out, I've been having this issue with UI tests where the test runner hangs for 60s when the keyboard is presented.
In the test logs I get this kind of messages:
00:07.588 Wait for com.example.app to idle
01:07.642 App event loop idle notification not received, will attempt to continue.
Interestingly, this only appears to be happening in CI environments (I've tried Xcode cloud and Circle CI). It works fine on my local machine.
Everything is fine with Xcode 14, but I can't keep my CI environment stuck on Xcode 14 forever.
I've tried disabling animations using UIView.setAnimationsEnabled(false), but it did not fix the problem.
Here are the full logs of what it takes to fill out a text field: logs.txt
Hi everyone, I'm quite new on this platform and I wanted to know as a dev if I want to test out a app do I need to download it from the App Store or is there a other way to test app on apple ?