Reuse the AVFoundation Swift files between iOS and macOS without
sprinkling `#if canImport(UIKit)` through them. The split is:
darwin/Camera/ platform-shared (AVFoundation only)
CameraPlugin channel + instance map
CameraInstance session + outputs + texture
CameraSession AVCaptureSession + runtime-error obs
CaptureDevice front/back discovery
PhotoOutput AVCapturePhotoOutput
PreviewSink CVPixelBuffer → FlutterTexture
VideoRecorder AVAssetWriter
DeviceOrientation wire-string enum
ios/Classes/Camera/ iOS-only impls + extensions
AudioSession AVAudioSession.upgradeForRecording
DeviceOrientationBridge UIDevice.orientation listener
CameraSession+iOS AVCaptureSessionWasInterrupted obs
+ InterruptionReason decode + the
application-audio-session flags
(all iOS-only on AVCaptureSession)
CameraSettings UIApplication.openSettingsURLString
FlutterRegistrar+iOS method-form of textures/messenger
macos/Classes/Camera/ macOS no-op stubs (same surface)
AudioSession no-op (no AVAudioSession on macOS)
DeviceOrientationBridge no-op (desktops don't rotate)
CameraSession+macOS no-op setupPlatform()
CameraSettings NSWorkspace → System Settings'
Privacy_Camera pane
FlutterRegistrar+macOS property-form of textures/messenger
`CameraSession.init` now calls `setupPlatform()` which each platform
provides via an extension — keeps the iOS-only interruption observer
and the `automaticallyConfiguresApplicationAudioSession` /
`usesApplicationAudioSession` flags (both iOS-only on AVCaptureSession)
out of the shared file. Flash-mode in PhotoOutput uses
`if #available(macOS 11/13, *)` rather than `#if`, since those are
plain version gates not platform splits.
The shared files compile into the iOS pod from `ios/Classes/Camera-shared/`
and into the macOS pod from `macos/Classes/Camera-shared/`, each a
mirror populated by a `prepare_command` in the podspec:
rm -rf Classes/Camera-shared && cp -R ../darwin/Camera Classes/Camera-shared
Symlinks and `../` source globs both fail — Pathname.glob bails on
symlinks, and CocoaPods silently drops paths that escape the pod
directory. The mirror destinations are .gitignore'd.
macOS UxPlugin now registers CameraPlugin alongside the others.
21 lines
1009 B
Ruby
21 lines
1009 B
Ruby
Pod::Spec.new do |s|
|
|
s.name = 'ux'
|
|
s.version = '0.9.0'
|
|
s.summary = 'UX Kit — Flutter plugin: keyboard, sensor, file, QR scanner, and camera.'
|
|
s.homepage = 'https://swipelab.co/ux.html'
|
|
s.license = { :file => '../LICENSE' }
|
|
s.author = { 'Swipelab' => 'hello@swipelab.co' }
|
|
s.source = { :path => '.' }
|
|
# Mirror the shared `darwin/Camera/` Swift files into a local
|
|
# `Classes/Camera-shared/` so CocoaPods picks them up via the
|
|
# normal glob — neither symlinks nor `../` escapes work
|
|
# (Pathname.glob bails on both). The mirror runs on every
|
|
# `pod install`; the destination is `.gitignore`'d.
|
|
s.prepare_command = 'rm -rf Classes/Camera-shared && cp -R ../darwin/Camera Classes/Camera-shared'
|
|
s.source_files = 'Classes/**/*.swift'
|
|
s.frameworks = ['AVFoundation', 'CoreMedia', 'CoreVideo', 'Photos', 'PhotosUI']
|
|
s.dependency 'Flutter'
|
|
s.ios.deployment_target = '13.0'
|
|
s.swift_version = '5.0'
|
|
end
|