swiftui-environment
CommunityShare data through SwiftUI with environment keys.
Software Engineering#environment#swiftui#preferences#dependency-injection#environmentkey#view-hierarchy
AuthorAutisticAF
Version1.0.0
Installs0
System Documentation
What problem does it solve?
SwiftUI data flow often requires prop drilling or boilerplate to share values across views. Environment provides downward data propagation, while Preferences allow child-to-ancestor communication of measurements and state for responsive UI behavior.
Core Features & Use Cases
- Define EnvironmentKey and extend EnvironmentValues to introduce shared values (e.g., theme, services) accessible across the view tree.
- Read values with @Environment and inject them via .environment() to enable dependency injection without explicit initializers.
- Use PreferenceKey and related modifiers such as .onPreferenceChange and .overlayPreferenceValue to propagate measurements and state upward through the hierarchy.
Quick Start
Define a custom EnvironmentKey, extend EnvironmentValues, inject it via .environment, and read it with @Environment in a sample view.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: swiftui-environment Download link: https://github.com/AutisticAF/claude-code-apple-dev-plugin/archive/main.zip#swiftui-environment Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.