Post

Replies

Boosts

Views

Activity

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) } } }
2
1
706
Oct ’25
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
302
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
525
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
500
Sep ’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
1.1k
Mar ’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) } } }
Replies
2
Boosts
1
Views
706
Activity
Oct ’25
Why does GIDSignIn.sharedInstance.signIn() return successfully when an INVALID bundle ID is used?
I find that GIDSignIn.sharedInstance.signIn() returns successfully when an INVALID bundle ID is used. Is this expected?
Replies
0
Boosts
0
Views
158
Activity
Feb ’25
"Multiple commands" error caused by name conflict
Please see detail here.
Replies
1
Boosts
0
Views
177
Activity
Feb ’25
How do I debug Google sign-in issue with SwiftUI?
I'm getting the following error Error Domain=com.google.GIDSignIn Code=-4. How do I find out what I'm missing with my setup of Google Cloud?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
173
Activity
Feb ’25
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?
Replies
0
Boosts
0
Views
302
Activity
Nov ’24
xcodebuild: error: Unable to find a destination matching the provided destination specifier
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.
Replies
0
Boosts
1
Views
557
Activity
Oct ’24
Why is a macOS build for my app not available in App Store Connect?
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.
Replies
2
Boosts
0
Views
437
Activity
Oct ’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.
Replies
1
Boosts
0
Views
525
Activity
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() } } }
Replies
2
Boosts
0
Views
500
Activity
Sep ’24
Unable to find a scheme that Xcloud Cloud complains about
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?
Replies
1
Boosts
0
Views
914
Activity
Jun ’24
Where does my Swift app's print output go during XCTest?
I only see the output from the XCTest itself. Xcode: Version 15.2 (15C500b)
Replies
4
Boosts
0
Views
3.3k
Activity
May ’24
How do I see all the feedback entries submitted by myself?
This is related to feedback submitted at https://feedbackassistant.apple.com.
Replies
4
Boosts
0
Views
953
Activity
May ’24
How do I enable QuickType bar for my password field in swiftUI?
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.
Replies
0
Boosts
0
Views
489
Activity
Mar ’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.
Replies
1
Boosts
0
Views
1.1k
Activity
Mar ’24
The build/run icon is disabled for a project in a workspace
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.
Replies
1
Boosts
0
Views
808
Activity
Nov ’23