A Swift learning project that demonstrates building a modern macOS video recording application using SwiftUI and AVFoundation.
This project is designed as a hands-on learning experience for Swift development on macOS. It implements a sleek, translucent video recording app that captures video and audio from connected devices.
This project covers essential Swift and macOS development concepts:
- SwiftUI Framework: Modern declarative UI development
- AVFoundation: Media capture and processing
- macOS App Development: Native macOS application structure
- State Management: Using
@StateObject
,@Published
, and@ObservableObject
- Permissions Handling: Camera and microphone access requests
- Custom UI Components: Translucent backgrounds and custom views
- Window Management: Custom window styling and behavior
- Audio Visualization: Real-time audio level monitoring
- Main app entry point using
@main
attribute - Custom
AppDelegate
for window management - Shared app state using
ObservableObject
- Translucent background implementation with
NSVisualEffectView
- Core recording functionality using
AVCaptureSession
- Device discovery and management (cameras/microphones)
- Permission handling for camera and microphone access
- Real-time audio level monitoring
- Recording state management
- ContentView.swift: Main interface with video preview
- PermissionsView.swift: Elegant permission request flow
- AudioWaveView.swift: Visual audio level representation
- AboutView.swift: Application information
- IntroView.swift: App introduction flow
- Window controllers for modular UI management
- Separation of concerns for different app windows
- Video recording with selectable cameras
- Audio recording with device selection
- Real-time preview with mirroring
- Permission request workflow
- Device discovery and switching
- Recording duration controls
- Audio level visualization
- Translucent, modern interface
- Fixed window size (340x730)
- Custom title bar styling
- Smooth animations and transitions
- Device picker interface
- Recording controls
- Native permission dialogs
- System menu integration
- Keyboard shortcuts
- Window management
@StateObject private var recorder = VideoRecorder()
@Published var isRecording = false
@EnvironmentObject private var appState: AppState
private var captureSession: AVCaptureSession?
private var movieOutput: AVCaptureMovieFileOutput?
let preview = AVCaptureVideoPreviewLayer(session: session)
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: // Handle authorized state
case .notDetermined: // Request permission
case .denied, .restricted: // Handle denied state
}
struct TranslucentBackgroundView: NSViewRepresentable {
func makeNSView(context: Context) -> NSVisualEffectView {
let view = NSVisualEffectView()
view.material = .dark
view.blendingMode = .behindWindow
return view
}
}
- Classes and Structs
- Protocols and Extensions
- Optionals and Error Handling
- Closures and Completion Handlers
- Property Wrappers (
@Published
,@StateObject
, etc.)
- SwiftUI: Views, Modifiers, State Management
- AVFoundation: Capture Sessions, Device Management
- Foundation: Timers, Notifications, Data Types
- AppKit: Window Management, Visual Effects
- MVVM (Model-View-ViewModel)
- Observer Pattern with Combine
- Delegation Pattern
- Singleton Pattern (for window controllers)
- Language: Swift 5.x
- Framework: SwiftUI
- Platform: macOS 11.0+
- IDE: Xcode 12.0+
- Study
ContentView.swift
for SwiftUI basics - Examine state management in
VideoRecorder.swift
- Understand permission flow in
PermissionsView.swift
- Custom UI components and animations
- AVFoundation session management
- Window styling and AppDelegate integration
- Performance optimization for video capture
- Custom visual effects and graphics
- Audio processing and visualization
- Translucent Design: Modern glass-morphism effect
- Fixed Dimensions: iPhone-like aspect ratio (340x730)
- Dark Theme: Optimized for video content
- Smooth Animations: Bouncy transitions and scaling effects
- Native Controls: macOS-style buttons and interfaces
The app demonstrates proper handling of sensitive permissions:
- Camera access for video recording
- Microphone access for audio capture
- Graceful error handling for denied permissions
- User-friendly permission request flow
- Add video filters and effects
- Implement video editing capabilities
- Add export format options
- Create settings persistence
- Add recording quality selection
- Implement batch recording features
- Add cloud storage integration
This project serves as an excellent foundation for understanding:
- How modern macOS apps are structured
- Integration between Swift UI and system frameworks
- Real-world permission and device handling
- Professional UI/UX design patterns in Swift
The codebase is well-organized and includes proper separation of concerns, making it easy to understand and extend as you continue your Swift learning journey.
Created: March 25, 2025
Purpose: Swift Learning Project
Platform: macOS
Framework: SwiftUI + AVFoundation