In the code below, the check for the toggle value passed in my xcode. However, it failed in cloud, i.e., that value was still "0" after being tapped.
func testToggle() throws {
let app = XCUIApplication()
app.launch()
let fieldName = "MyToggle"
let field = app.switches[fieldName]
XCTAssertTrue(field.exists, "Field '\(fieldName)' should exist|debug = \(app.debugDescription)")
let firstMatch = field.switches.firstMatch
firstMatch.tap()
#if FAILED_XCODE_CLOUD
// Verify the toggle/switch is in the desired state
XCTAssertEqual(firstMatch.value as? String, "1", "Field '\(fieldName)' should be ON|debug = \(app.debugDescription)") // "1" is On, "0" is Off
#endif
}
In addition, I'd also like to ask why a traverse to firstMatch is needed?
Post
Replies
Boosts
Views
Activity
I added a new target for macOS to my existing iPhone app. The new target ran successfully in Xcode. However, when I committed the changes, Xcode Cloud generated the error.
I don't know what the error means. Would someone please give me a pointer? Thank you.
The macOS build is available in TestFlight. But when I go to App Store Connect to prepare it for submission, I don't see any macOS version in the "Build" section.
I have a + image in the UI from the following code
struct QueryPlusButton: View {
var body: some View {
Button {
}
label: {
Image(systemName: "plus")
}
}
}
However, I'm not able to query the + image in XCTest using any of the following queries
let view = app.images["plus"]
//let view = app.staticTexts["plus"]
//let view = app.buttons["plus"]
XCTAssertTrue(view.exists, "Plus button does not exist")
The test fails. Is there a methodical way to determine what a query is for any UI element? Thank you.
In the code below, for the #else case, when I click Click to dismiss, the button remains. But for the #if DISMISS_SUCCESSFULLY case, clicking the button causes pops it of the navigation stack. Would you please help explain why the difference? Thank you.
Button("Click to navigate") {
myNavigate = true
}
.navigationDestination(isPresented: $myNavigate) {
#if DISMISS_SUCCESSFULLY
DismissButton()
#else
Button("Click it dismiss") {
print("Dismissing ...")
presentationMode.dismiss()
print("Done dismissing")
}
#endif
}
struct DismissButton: View {
//=== Local ===
@Environment(\.presentationMode) @Binding private var presentationMode
var body: some View {
Button("Click it dismiss") {
presentationMode.dismiss()
}
}
}
Xcode Cloud reports the following error
A scheme called PlatoSafe does not exist in Plato.xcodeproj
However, my project only has one scheme named Plato. I search the proj using git grep PlatoSafe and don't see such a name anywhere. I do xcodebuild -list, and the output shows Plato as the only scheme.
Where does Xcode Cloud get the scheme name PlatoSafe from?
I only see the output from the XCTest itself.
Xcode: Version 15.2 (15C500b)
When I run the code below, the trace, "Called", is shown 3-4 times initially. If I click on a color row, the trace shows 9 times. Why is that?
If I comment out the line, @Environment(\.dismiss) private var dismiss, the trace shows only 1 time, as expected.
I've read a number of reports regarding dismiss() which seems to be very brittle. It often causes an infinite loop. But I need to dismiss a view. Its older counterpart, @Environment(\.presentationMode), seems to cause infinite loop at times. Are there other ways to dismiss a view without suffering these issues?
struct TestNavigationLink: View {
@Environment(\.dismiss) private var dismiss
var body: some View {
let _ = print("Called")
NavigationStack {
List {
NavigationLink("Mint") { ColorDetail(color: .mint) }
}
.navigationTitle("Colors")
}
} // body
struct ColorDetail: View {
var color: Color
var body: some View {
color.navigationTitle(color.description)
}
}
}
This is related to feedback submitted at https://feedbackassistant.apple.com.
I'm not able to follow this documentation to get the same screen as shown. I've set the content type and keyboard type as suggested. Not sure what else I'm missing? Is there full example code for it? Thank you.
Xcode: Version 15.2 (15C500b)
I encounter this error even with a Hello world app that I created from scratch using Xcode -> File -> New -> Project.
Below are the errors
Asset validation failed
Missing Info.plist value. A value for the Info.plist key 'CFBundleIconName' is missing in the bundle 'alodotad.test-1'. Apps built with iOS 11 or later SDK must supply app icons in an asset catalog and must also provide a value for this Info.plist key. For more information see http://help.apple.com/xcode/mac/current/#/dev10510b1f7. (ID: b9c6bcae-6ea1-4343-b173-e2c3c71f2ec9)
Asset validation failed
Missing required icon file. The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format for iOS versions >= 10.0. To support older versions of iOS, the icon may be required in the bundle outside of an asset catalog. Make sure the Info.plist file includes appropriate entries referencing the file. See https://developer.apple.com/documentation/bundleresources/information_property_list/user_interface (ID: 02055686-c98c-4823-8041-9a77e46af895)
I then made changes to include the key CFBundleIconName in Info.plist, and that my AppIcon file has 120x120.png icon. What else do I need to check?
I've gone thru many posts regarding the same error, and I'm still unable to fix it. Thank you for your help.
I have a workspace with a Hello-world project. The Start icon is disabled. When I try to create a new scheme (Product -> Scheme -> New Scheme), the Target field shows None.
May I ask how I get the Start icon active, so I can build/run the project in the workspace?
Xcode Version 15.0 (15A240d)
Thank you.
My app will require user's login. I'd like it to use face ID, and fallback on other things like password. Is there a reusable Swift module/package for that? Thank you.
My enrollment has been completed. However, when I open the app, click on the “Account” option, the app grays out the “Enroll now” option, instead of saying something like “(Already) Enrolled”. I find that confusing. Please consider updating that. Thank you.
I'd like to learn and try things out without the need to have access to my Apple device. Currently, I'm regularly on a Windows machine, and I find it a bit inconvenient to switch my work setup/environment; I'd like to have access to Swift and SwiftUI at my fingertips.