Post

Replies

Boosts

Views

Activity

Reply to ProductView failed to trigger purcahse flow.
Hi, Some good news! I finally decided to try another route to get around this. The app review team finally approved my app. I still don't know what happened to the ProductView. The handling for transaction could go wrong but the purchase flow should be triggered correctly. Simply replace the product view with some custom code if store.activeTransactions.isEmpty { ForEach(store.products, id: \.id) { product in Button { Task { try await store.purchase(product) } } label: { VStack { Text(verbatim: product.displayName) .font(.headline) Text(verbatim: product.displayPrice) } } .buttonStyle(.borderedProminent) } And in the Store class func purchase(_ product: Product) async throws { let result = try await product.purchase() switch result { case .success(let verificationResult): if let transaction = try? verificationResult.payloadValue { activeTransactions.insert(transaction) await transaction.finish() } case .userCancelled: break case .pending: break @unknown default: break } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’25
Reply to Get MacOS menubar size in Swift
Thanks! Just tried that solution. I am getting 34. Using same method to measure, it is the height of the notch. Unfortunately, the menubar seems a little taller than the notch. I measured 37px and i can see the additional pixel with my eye when the menubar is not black. This one is very close!
Topic: UI Frameworks SubTopic: AppKit Tags:
Apr ’25
Reply to XCTEST a bit trouble on not seeing the statusbar
I can find a solution but it is not very nice. It seems there is no API to trigger the statusbar directly. The following is suggested by ChatGPT import XCTest import CoreGraphics func moveMouseToTop() { let screenHeight = NSScreen.main?.frame.height ?? 900 let topPoint = CGPoint(x: 100, y: 2) // Move near the top edge let move = CGEvent(mouseEventSource: nil, mouseType: .mouseMoved, mouseCursorPosition: topPoint, mouseButton: .left) move?.post(tap: .cghidEventTap) } class StatusBarTests: XCTestCase { func testClickStatusBarIcon() { let app = XCUIApplication(bundleIdentifier: "your.app.bundle.identifier") app.launch() moveMouseToTop() // Ensure status bar is visible let statusBar = XCUIApplication(bundleIdentifier: "com.apple.systemuiserver") let statusBarItem = statusBar.menuBars.children(matching: .button).element(boundBy: 0) // Adjust index for your icon XCTAssertTrue(statusBarItem.exists) statusBarItem.click() } }
Feb ’25