Repository navigation
Apple camera capture: thicket-camera-apple over UIImagePickerController (iOS); macOS Camera.unavailable (#129) - #143
Conversation
…camera checks Not yet run on the simulator. shimGen: CameraConsistencySpec 7/7, generated files current; libthicketcamera.a 57 144 bytes (simulator). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… XCUITest
Measured: isSourceTypeAvailable(.camera) is true on the iOS 27 simulator ('iPhone Air'),
and the picker shows a simulated grey frame. The tapper gains 'app <bundle> <labels>'.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tapper stops at its answer Camera-only run on 'iPhone Air' (iOS 27): 6 camera checks pass. The X answers no photo 6.5-9.3 s after the DRIVE line; the shutter took nothing in 60 s (no review screen). The tapper's Tear Down took ~300 s on every tap (measured 301.9 and 304.0 s), so tap.sh now stops xcodebuild by PID once the test prints '[tapper] done'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bin-free run of examples/gallery/ios/ios-app/build-app.sh: ALL CHECKS PASSED, 213 ok, after simctl privacy reset of the gallery (the notifications flake). Control: a cancel not delivered fails 'closing the camera screen with its X answers no photo'. WAIT_SECONDS 480. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bin/verify-apple.sh 'iPhone Air': 19/19 steps on d1e524b. iOS gallery 213, macOS gallery 197 twice (screen locked). shimGen 44 (CameraConsistencySpec 7). The iOS 27 simulator has a camera screen whose shutter takes nothing (60 s, 5 runs): the capture path is unmeasured (no device). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
Approval is blocked because the review evidence identifies critical unresolved issues: an incompatible Android→iOS Scala Native project dependency and outdated/misleading simulator camera availability documentation in both source and generated ABI docs.
2 open issues
What changed in this PR
This pull request adds Apple camera capture support by introducing a new iOS thicket-camera-apple implementation backed by UIImagePickerController via a packaged Swift static library and a small C ABI bridge, while explicitly keeping macOS camera behavior as unavailable. It also extends shim-gen tooling, Apple verification scripts, and gallery/self-test coverage to exercise the camera UI as far as the iOS simulator allows.
Changes:
- Add
modules/camera-apple(Scala Native + Swift shim + generated header/externs) and wire it into sbt and iOS gallery builds. - Extend
tools/shim-genwith camera ABI definitions, emit/parsing support, and a consistency spec to keep Swift/C/Scala bindings aligned. - Update Apple gallery demos, self-tests, tapper tooling, verification scripts, and documentation/status tables to reflect iOS camera capability and macOS unavailability.
| File | Summary |
|---|---|
| tools/shim-gen/src/test/scala/thicket/tools/shim/CameraConsistencySpec.scala | Adds camera ABI/header/externs/Swift consistency tests. |
| tools/shim-gen/src/main/scala/thicket/tools/shim/Parse.scala | Extends shim parsing for camera callback types. |
| tools/shim-gen/src/main/scala/thicket/tools/shim/Main.scala | Integrates camera header/extern generation into shim-gen outputs. |
| tools/shim-gen/src/main/scala/thicket/tools/shim/Emit.scala | Emits generated camera C header and Scala externs. |
| tools/shim-gen/src/main/scala/thicket/tools/shim/CameraAbi.scala | Defines the thk_cam_* ABI surface for camera capture. |
| tools/sbt-thicket/src/main/scala/thicket/sbt/ThicketApplePlugins.scala | Adds sbt tasks to unpack/link the camera shim for iOS. |
| tools/sbt-thicket/README.md | Documents the new iOS camera shim unpack task. |
| README.md | Updates repository/module documentation to include camera-apple. |
| modules/camera/README.md | Documents Apple camera behavior, permissions, and cache-copy flow. |
| modules/camera-apple/src/main/scala/thicket/camera/apple/CameraShim.scala | Generated Scala Native extern bindings for the camera shim. |
| modules/camera-apple/src/main/scala/thicket/camera/apple/AppleCamera.scala | Implements iOS camera capture using the Swift shim and cache copying. |
| modules/camera-apple/shim/Sources/CameraShim.swift | Swift implementation presenting UIImagePickerController and returning a temp JPEG path. |
| modules/camera-apple/shim/include/thicket_camera.h | Generated C header for the camera shim ABI. |
| modules/camera-apple/shim/build-shim.sh | Script to build libthicketcamera.a for iOS simulator. |
| modules/camera-apple/.gitignore | Ignores built shim outputs. |
| examples/ios-host/tapper/TapperUITests/TapperUITests.swift | Extends tapper UI test helper to support in-app tapping by bundle id/labels. |
| examples/ios-host/tapper/tap.sh | Stops xcodebuild after tap completion; extends tap invocation syntax. |
| examples/gallery/shared/shared/src/main/scala/example/gallery/PickersDemo.scala | Adds a “NoPickers” path to allow camera-only UI where pickers aren’t available. |
| examples/gallery/shared/shared/src/main/scala/example/gallery/Gallery.scala | Updates gallery UI to show camera when pickers are absent. |
| examples/gallery/README.md | Documents Apple camera checks and simulator limitations. |
| examples/gallery/macos/src/main/scala/example/gallery/GalleryMac.scala | Sets macOS camera as Camera.unavailable(...). |
| examples/gallery/ios/src/main/scala/example/gallery/GalleryIos.scala | Wires AppleCamera into iOS services and self-test hooks. |
| examples/gallery/ios/ios-app/build-app.sh | Links the camera shim and configures iOS build/run for camera permission usage. |
| examples/gallery/apple-shared/src/main/scala/example/gallery/GallerySelfTest.scala | Adds camera checks into the Apple self-test sequence. |
| examples/gallery/apple-shared/src/main/scala/example/gallery/GalleryDeviceChecks.scala | Adjusts device permission expectations (iOS vs macOS) for camera. |
| examples/gallery/apple-shared/src/main/scala/example/gallery/GalleryCameraChecks.scala | Adds camera-specific self-test logic including simulator behavior handling. |
| docs/decisions.md | Records decision log entry for Apple camera capture approach and findings. |
| docs/16-device-services.md | Updates device-services status/plans for iOS camera support. |
| docs/14-releasing.md | Adds thicket-camera-apple to release/publish documentation. |
| docs/12-component-status.md | Updates component status entry for Apple camera support. |
| build.sbt | Adds the cameraApple project and wires it into the build graph. |
| bin/verify-apple.sh | Adds a shim-camera verification/build step. |
| .scalafmt.conf | Excludes generated CameraShim.scala from formatting. |
Review effort: Balanced
Clarified camera availability notes in documentation. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
a22fed9, edited outside sbt, left one Scaladoc line past the width; this is sbt scalafmtAll's reflow and nothing else. platforms/Test/compile: 0 errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both add a gallery section and a tapper form: - build.sbt, README, docs/14: cameraApple and shareApple both. - GallerySelfTest: motion -> camera -> share -> clipboard -> sheet; share stays right before the clipboard (#134). - build-app.sh drive(): photo and cancel (#129) and share-copy (#134). - Tapper: three forms. "app <bundle id> a|b" (#129) is checked before '<bundle id>|<label>' (#134), since the first also has '|' in it. Every form now prints "[tapper] done" or "[tapper] failed" (#129's signal; #134's form gained both, its assertion now a guard). tap.sh is one wait-and-kill loop on those lines (both PRs had one, for the same 300 s tear-down), rebuilding when a .swift is newer than the build. "[tapper] tapped" no longer ends the wait: #129's form taps more than once. - docs/12: Camera's row from #129, Share's from main; both counts, measured apart. decisions.md: both entries. Checked here: sbt scalafmtAll and platforms/Test/compile, 0 errors; bash -n on tap.sh and build-app.sh. Not checked: the Swift tapper compiling, and any Apple self-test (they need the Mac); the combined gallery is unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both add a Swift library through shim-gen and sbt-thicket, and a gallery section driven by the tapper, so they meet in 17 files; everything is kept: - shim-gen: Emit has pickers' and camera's header/extern emitters (main's file plus #143's two functions), Main generates all, Parse knows both callback types. sbt-thicket: ThicketPickersApple and ThicketCameraApple, both keys and settings. .scalafmt.conf excludes both generated externs. - build.sbt, verify-apple.sh (shim-pickers and shim-camera), docs 12/14/16. - Galleries: GallerySelfTest.run takes camera and pickers; the chain is motion -> camera -> share -> clipboard -> pickers -> sheet. GalleryIos builds both. build-app.sh links both libraries, has both DRIVE action sets (pick-photo/cancel-photo/... and photo/cancel), WAIT_SECONDS 600 (each alone fit in 480; together not measured). - Tapper: main's actions (#125, #134) with #129's "app <id> a|b" form checked first; done() now prints "[tapper] done", which every form ends with, and tap.sh is #143's wait-and-kill loop on done/failed, passing #125's TEST_RUNNER_APP and TEST_RUNNER_FILE. Checked here: sbt scalafmtAll and platforms/Test/compile, 0 errors; shimGen 51/51 (with the next commit), sbtThicket 13/13; bash -n on tap.sh and build-app.sh. Not checked: the Swift (tapper, shims) compiling, and any Apple self-test; the gallery with both sections is unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7ba279a changed thk_cam_available's doc in CameraAbi.scala but not the header generated from it, so shimGen's "checked-in generated files are exactly what Abi generates" failed (stale: thicket_camera.h). This is `sbt shimGen/run`'s output and nothing else. shimGen 51/51 after (50/51 before). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict only in docs/decisions.md: both 2026-11-02 entries kept, the embedding point's on top; the 11-01 camera-preview entry appears once (#144). #143 and #144 are Apple code and docs, so the GTK (144) and Android (95) counts measured on this branch stand. Checked here: sbt scalafmtAll, Test/compile and platforms/Test/compile, 0 errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ple (#147) #142 and #143 each added their Apple module (Scala Native) to the Android gallery's dependsOn, beside the Android one; the Android gallery uses neither, and build.sh packages its own jar list, which never had them. Measured: galleryAndroid/compile and platforms/Test/compile, 0 errors; SELFTEST=1 examples/gallery/android/build.sh on s2test, 95 checks, ALL CHECKS PASSED (95 before as well). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>


Closes #129.
What
thicket-camera-apple(iOS):AppleCamera(cache)presentsUIImagePickerControllerwithsourceType = .camera. The.originalImageis written as a JPEG (quality 0.9) to a temp file by the Swift library, copied into the cache throughPickedFiles, and the temp file is deleted. Cancel answersNone, and only one request runs at a time.availability: ifNSCameraUsageDescriptionis missing it throwsIllegalStateExceptionnaming the key (throughApplePermissions). Otherwise it isUnavailable("This device has no camera")whenisSourceTypeAvailable(.camera)is false,NeedsPermission(Camera)while the permission is not yet asked or is denied, andUnavailablewhen restricted.libthicketcamera.a, 57 144 bytes, simulator only).UIImagePickerControllerDelegateis an Objective-C protocol, so it needs an Objective-C class. ABI:CameraAbi(thk_cam_*, 3 functions) withCameraConsistencySpec(7 tests). Also new: ashim-camerastep inverify-apple.shandthicketCameraAppleinThicketIosPlugin.Camera.unavailable("no camera screen on the desktop"), matching GTK.Grantedon iOS. macOS still checks that it throws.Finding: the simulator has a camera
On the iOS 27 simulator
isSourceTypeAvailable(.camera)is true. The picker shows a grey simulated frame, but its shutter takes nothing: no review screen and no delegate call within 60 s (5 runs) or 300 s (2 runs). The iOS checks are therefore:Noneand the first stays upNone(6.3–9.7 s after the DRIVE line)Not measured: a JPEG (
FF D8 FF) coming back into the cache after a capture, with the temp file removed. The self-test checks for it, but only a device can run that path, and none was available. The no-camera path ("Take a photo" presents nothing) is also unmeasured.Tapper fix (affects #114/#118 checks)
On Xcode 27, the XCUITest tapper's Tear Down took ~300 s after every tap (301.9 s, 304.0 s), with or without other simulators busy. That held back later DRIVE lines and failed the location checks in 3 of 3 runs.
tap.shnow stops xcodebuild by PID once the test prints[tapper] done. After the change, "Don't Allow" was answered 6.3 s after its DRIVE line and the location checks passed. The tapper also acceptsapp <bundle id> <label>|?<label>.Measured
bin/verify-apple.sh "iPhone Air": 19/19 steps ond1e524b.shimGen44;shimGen/run --checkcurrent.simctl privacy reset allon the gallery, it passed.Control
Not delivering a cancel's answer made "closing the camera screen with its X answers no photo" fail (
None; presented false). The control the issue proposed (availability ignoringisSourceTypeAvailable) can't fail on a simulator that has a camera, so it was not run.🤖 Generated with Claude Code