Skip to content

test(ios): approve the document fixture's scheme before opening its link - #2381

Merged
houko merged 1 commit into
mainfrom
fix/ios-document-types-e2e
Nov 25, 2026
Merged

houko merged 1 commit into
mainfrom
fix/ios-document-types-e2e

Conversation

@houko

@houko houko commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Symptom

Test / apple-simulator has failed on every run that reached it since #2034 landed (first on c8ea22b, 2026-11-22, and twice for the v0.3.2 release, run 45585895359): in TestIOSDocumentTypesEndToEnd the cold and warm document cases pass, then the sender's link case fails with openfiles_test.go:241: UIKit did not answer the custom-link request. Pull requests skip apple-simulator, so #2034's own runs never exercised it on CI.

Root cause

The test, not the product. Before one app opens another app's custom URL scheme, LaunchServices (_LSSchemeApprovalFindWithCompletionHandler in CoreServices) shows SpringBoard's "“ios” wants to open “NSGo Documents”" alert unless the two apps share a team ID, the caller is Apple's, or the user already allowed that source and scheme. Simulator builds are signed ad hoc, with no team ID, so on a fresh simulator the sender's UIApplication openURL:options:completionHandler: waits for the user's answer, and UIKit calls the completion only after a tap that nothing in the test can make. Reproduced on a fresh iOS 26.5 simulator: the sender stays inactive under the alert for the full 10 seconds, and the alert is still up after the test ends, which also makes the next run's sender fail to become active. A real touch on an NSGo view before OpenURL does not avoid the prompt. Scope.OpenURL behaves correctly: it reports the outcome once the user answers.

Fix

Before the link case, the end-to-end test records the approval LaunchServices reads before it prompts: in the simulator's com.apple.launchservices.schemeapproval preferences, the key <sender bundle ID>--><scheme> with the receiver's bundle ID as its value (xcrun simctl spawn <udid> defaults write ...). The test deletes the key when it ends. The sender still opens the link through UIApplication's public openURL, so UIKit still creates the receiver's real URL context.

Tests

On a Mac Studio (Xcode 27.1, iOS 26.5 simulator), with the job's command NSGO_SIMULATOR_E2E=1 go tool nsgo test -run '^TestIOSDocumentTypesEndToEnd$' ./cmd/nsgo -- -timeout=15m:

  • Before: ✗ TestSystemDocumentOpenInRoutesToRegisteredApp (10.78s) / openfiles_test.go:241: UIKit did not answer the custom-link request, the same failure as CI.
  • After, on a freshly erased simulator: ✓ TestIOSDocumentTypesEndToEnd (1m36.24s), and again on the same simulator: ✓ TestIOSDocumentTypesEndToEnd (26.63s). Afterwards defaults read com.apple.launchservices.schemeapproval reports that the domain does not exist.
  • go tool nsgo check passes.

No changelog fragment: only a test changes.

Screenshots: none

LaunchServices asks the user before one app opens another app's custom scheme unless the two share a team ID or the user already allowed the pair. Simulator builds are signed ad hoc without a team ID, so on a fresh simulator the sender's openURL waited behind a SpringBoard alert that nothing in the test can tap, and the link case of TestIOSDocumentTypesEndToEnd timed out on every apple-simulator run since it landed. Record the approval LaunchServices reads before prompting, and remove it when the test ends.
@houko
houko enabled auto-merge (rebase) November 25, 2026 10:22
@houko
houko merged commit aa199f0 into main Nov 25, 2026
41 of 42 checks passed
@houko
houko deleted the fix/ios-document-types-e2e branch November 25, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant