feat: pair a phone by scanning one code instead of copying two - #202
Merged
Conversation
Setting up the phone meant copying two long opaque strings from Mac Settings into two fields on the phone, with no QR code and a five minute window that gave no hint it was running out. That was the biggest thing standing between a new tester and a working companion. Now the Mac shows a QR code and one combined link, with a live countdown, and the phone can scan it with the camera or take a single paste. The old two-field path is still there behind a disclosure, so nothing breaks if the camera is unavailable or a tester prefers pasting. Also adds a README with the setup steps, including the two easy things to get wrong: the Mac toggle is off by default, and both devices have to be on the same iCloud account for background notifications. The combined code carries a version marker that both sides check, so a newer Mac cannot quietly hand an older phone a format it would misread. The phone ships through TestFlight and will lag the Mac app, so that skew is the normal case rather than an edge one.
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.
What this does
Setting up the phone used to mean copying two long opaque strings out of Mac
Settings and pasting them into two separate fields, with a five minute window
that gave no sign it was running out. That was the biggest thing between a new
tester and a working companion.
Now the Mac shows a QR code plus one combined link with a live countdown, and the
phone either scans it or takes a single paste. The old two-field path stays as a
fallback, so nothing breaks when the camera is unavailable.
There is also a README covering the two easy things to get wrong: the Mac toggle
is off by default, and both devices need the same iCloud account for background
notifications.
Summary
programa-pair://pair?v=1&t=<ticket>&k=<token>, witha parser on each side. The two app targets share no module, so the copies are
kept in sync by hand and both files say so.
v. A newer Mac cannot hand an older phone a format itwould misread — the phone ships through TestFlight and will lag the Mac app, so
that skew is the normal case, not an edge one.
beginPairing()now returnsMobileBridgePairingInfowith a realexpiresAtread from
mobileBridgePairingWindowDuration, not a hardcoded 300s. That drivesthe countdown.
expired state. Original ticket/token rows preserved behind a
DisclosureGroup.AVCaptureMetadataOutputscanner sheet handling the not-determined,denied and restricted permission states, degrading gracefully with no camera
(simulator).
NSCameraUsageDescriptionadded insideinfo.propertiesonly —mixing it with
INFOPLIST_KEY_*silently drops keys, asproject.yml:33-50documents.
Review order
Sources/MobileBridge/MobileBridgePairingCode.swiftandios/ProgramaSpike/ProgramaSpike/PairingCode.swift— the format contract, andthe only place the two targets can drift.
Sources/SettingsView.swift— the Mac pairing UI.ios/ProgramaSpike/ProgramaSpike/{QRScannerView,PairConnectView,AppStore}.swift.Known gap
The new iOS strings are bare English literals. The iOS target has no String
Catalog and its existing convention is literals, so this matches what is there —
but it does not meet the repo-wide localization rule the Mac side follows. Adding
that infrastructure is worth its own change before Japanese testers see this.
Test Plan
./scripts/reload.sh --tag ios-pair-qr→ exit 0 (verified)xcodebuild ... -destination 'generic/platform=iOS'→** BUILD SUCCEEDED **(verified)/usr/libexec/PlistBuddy -c "Print :NSCameraUsageDescription" ios/ProgramaSpike/ProgramaSpike/Info.plistprints the description (verified)