Files
zqxwceandClaude Opus 4.7 1aab0d6e25 camera: discover AVCapturePhoto + resolvedSettings selectors at runtime
Replace the two giant hardcoded selectors (the 27-arg AVCapturePhoto
init and the 32-arg +resolvedSettingsWithUniqueID:… factory) with a
prefix-lookup + label-driven NSInvocation builder. This survives
Apple adding or removing args between iOS releases without code
changes: the discovered selector decides arg count and order, the
resolver block fills the args we care about by label
("timestamp", "photoSurface", "uniqueID", "photoDimensions", etc.),
and unknown labels get nil/zero from the runtime type encoding.

  cfx_find_selector_by_prefix(cls, prefix, classMethod)
      Walks class_copyMethodList on cls (or its metaclass for class
      methods), returns the matching selector with the most colons.
      Highest-arg-count match wins so a future Apple revision that
      adds a new arg in the middle is still found.

  cfx_normalize_first_label(NSString *)
      Strips "initWith" / "resolvedSettingsWith" and lowercases the
      first char of the remainder so the leading component matches
      the same label convention as the rest of the selector.

  cfx_invoke_with_labeled_args(target, selector, resolver)
      Builds the NSInvocation, iterates selector components, calls
      the resolver block once per arg with (label, typeEnc, outBuf).
      Block writes the value via the appropriate cast (CMTime,
      IOSurfaceRef, __unsafe_unretained id, NSInteger, etc.) or
      leaves outBuf zeroed.

Builders refactored:
  - cfx_build_resolved_settings now fills only uniqueID +
    photoDimensions + previewDimensions; everything else stays
    zero/nil (Apple's impl tolerates that on builds where the
    factory itself works at all).
  - cfx_build_avcapturephoto_with_request fills timestamp,
    photoSurface, photoSurfaceSize, processedFileType, metadata,
    captureRequest, sequenceCount, photoCount, sourceDeviceType.
    Every other surface/dictionary arg defaults to nil.

End state: net +169/-96 lines, zero hardcoded full selectors,
photo synthesis remains functionally identical on 26.5 and is
prepared for arg-list drift on future iOS revisions.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-06-20 01:12:16 +03:00
..