Repository navigation
test(ios): approve the document fixture's scheme before opening its link - #2381
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Test / apple-simulatorhas 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): inTestIOSDocumentTypesEndToEndthe cold and warm document cases pass, then the sender's link case fails withopenfiles_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 (
_LSSchemeApprovalFindWithCompletionHandlerin 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'sUIApplication 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 beforeOpenURLdoes not avoid the prompt.Scope.OpenURLbehaves 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.schemeapprovalpreferences, 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 publicopenURL, 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:✗ TestSystemDocumentOpenInRoutesToRegisteredApp (10.78s)/openfiles_test.go:241: UIKit did not answer the custom-link request, the same failure as CI.✓ TestIOSDocumentTypesEndToEnd (1m36.24s), and again on the same simulator:✓ TestIOSDocumentTypesEndToEnd (26.63s). Afterwardsdefaults read com.apple.launchservices.schemeapprovalreports that the domain does not exist.go tool nsgo checkpasses.No changelog fragment: only a test changes.
Screenshots: none