Post

Replies

Boosts

Views

Activity

Why is Toggle's value not changed in Xcode cloud?
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?
0
0
139
Nov ’24
How do I query the "+" button in XCTest?
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.
1
0
299
Sep ’24
Why does dismiss() have no impact inside a closure of NavigationDestination view?
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() } } }
2
0
309
Sep ’24
Simply including "@Environment(\.dismiss) ..." causes multiple calls to a view's body
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) } } }
1
1
417
May ’24
Xcode's archive validation error "Missing Info.plist value" for a "Hello world" project
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.
1
0
780
Mar ’24