返回顶部
f

fosmvvm-swiftui-app-setupFOSMVVM应用配置

Set up the @main App struct for FOSMVVM SwiftUI apps. Configures MVVMEnvironment, deployment URLs, and test infrastructure.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 2.0.6
安全检测
已通过
623
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

fosmvvm-swiftui-app-setup

FOSMVVM SwiftUI App Setup

Generate the main App struct for a SwiftUI application using FOSMVVM architecture.

Conceptual Foundation

For full architecture context, see FOSMVVMArchitecture.md | OpenClaw reference

The App struct is the entry point of a SwiftUI application. In FOSMVVM, it has three core responsibilities:

CODEBLOCK0

Core Components

1. MVVMEnvironment

The MVVMEnvironment provides FOSMVVM infrastructure to all views:

CODEBLOCK1

Key configuration:

  • - appBundle - Usually Bundle.main (the app bundle)
  • INLINECODE3 - Array of localization bundles from your modules
  • INLINECODE4 - URLs for each deployment environment

Resource Bundle Accessors:

Each module that contains localization resources should provide a bundle accessor:

CODEBLOCK2

This pattern:

  • - Uses Bundle.module which SPM automatically provides for each module
  • Provides a clean public API for accessing the module's resources
  • Keeps bundle access centralized in one place per module

2. Environment Injection

The MVVMEnvironment is injected at the WindowGroup level:

CODEBLOCK3

This makes the environment available to all views in the hierarchy.

3. Test Infrastructure

The test infrastructure enables UI testing with specific configurations:

.testHost { } modifier:
CODEBLOCK4

Key points:

  • - Apply to the top-level view in WindowGroup (the outermost view in your hierarchy)
  • This ensures the modifier wraps the entire view hierarchy to intercept test configurations
  • Always include the default: case
  • The default case detects test mode via process arguments
  • Sets @State private var underTest = false flag
  • Optional: Add specific test configurations for advanced scenarios

registerTestingViews() function:
CODEBLOCK5

Key points:

  • - Extension on the App struct (not MVVMEnvironment)
  • Called from INLINECODE11
  • Registers every ViewModelView for isolated testing
  • DEBUG only

When to Use This Skill

  • - Starting a new FOSMVVM SwiftUI application
  • Migrating an existing SwiftUI app to FOSMVVM
  • Setting up the App struct with proper FOSMVVM infrastructure
  • Configuring test infrastructure for UI testing

What This Skill Generates

ComponentLocationPurpose
Main App structINLINECODE12Entry point with MVVMEnvironment setup
MVVMEnvironment configuration
Computed property in App struct | Bundles and deployment URLs | | Test infrastructure | DEBUG blocks in App struct | UI testing support |

Project Structure Configuration

PlaceholderDescriptionExample
INLINECODE13Your app nameINLINECODE14, INLINECODE15
INLINECODE16
Main app target | App | | {ResourceBundles} | Module names with localization | MyAppViewModels, SharedResources |

How to Use This Skill

Invocation:
/fosmvvm-swiftui-app-setup

Prerequisites:

  • - App name understood from conversation context
  • Deployment URLs discussed or documented
  • Resource bundles identified (modules with localization)
  • Test support requirements clarified

Workflow integration:
This skill is used when setting up a new FOSMVVM SwiftUI application or adding FOSMVVM infrastructure to an existing app. The skill references conversation context automatically—no file paths or Q&A needed.

Pattern Implementation

This skill references conversation context to determine App struct configuration:

Configuration Detection

From conversation context, the skill identifies:

  • - App name (from project discussion or existing code)
  • Deployment environments (production, staging, debug URLs)
  • Resource bundles (modules containing localization YAML files)
  • Test infrastructure (whether UI testing support needed)

MVVMEnvironment Setup

Based on project structure:

  • - App bundle (typically Bundle.main)
  • Resource bundle accessors (from identified modules)
  • Deployment URLs (for each environment)
  • Current version (from shared module)

Test Infrastructure Planning

If test support needed:

  • - Test detection (process arguments check)
  • Test host modifier (wrapping top-level view)
  • View registration (all ViewModelViews for testing)

File Generation

  1. 1. Main App struct with @main attribute
  2. MVVMEnvironment computed property
  3. WindowGroup with environment injection
  4. Test infrastructure (if requested, DEBUG-only)
  5. registerTestingViews() extension (if test support)

Context Sources

Skill references information from:

  • - Prior conversation: App requirements, deployment environments discussed
  • Project structure: From codebase analysis of module organization
  • Existing patterns: From other FOSMVVM apps if context available

Key Patterns

MVVMEnvironment as Computed Property

The MVVMEnvironment is a computed property, not a stored property:

CODEBLOCK6

Why computed?

  • - Keeps initialization logic separate
  • Can be customized in DEBUG vs RELEASE
  • Clear dependency on bundles and URLs

Test Detection Pattern

The default test detection uses process arguments:

CODEBLOCK7

Why this approach?

  • - Simple and reliable for DEBUG builds
  • No additional dependencies
  • Process arguments are set by test runner

Register All ViewModelViews

Every ViewModelView should be registered for testing:

CODEBLOCK8

Organization tips:

  • - Group by feature/screen with comments
  • Alphabetical order within groups
  • One view per line for easy scanning

Common Customizations

Multiple Environment Values

You can inject multiple environment values:

CODEBLOCK9

Conditional Test Registration

You can conditionally register views based on build configuration:

CODEBLOCK10

Advanced Test Configurations

You can add specific test configurations in .testHost:

CODEBLOCK11

File Templates

See reference.md for complete file templates.

Naming Conventions

ConceptConventionExample
App structINLINECODE23INLINECODE24, INLINECODE25
Main file
{Name}App.swift | MyApp.swift | | MVVMEnvironment property | mvvmEnv | Always mvvmEnv | | Test flag | underTest | Always underTest |

Deployment Configuration

FOSMVVM supports deployment detection via Info.plist:

CODEBLOCK12

Local development override:

  • - Edit Scheme → Run → Arguments → Environment Variables
  • Add: INLINECODE32

See Also

Version History

VersionDateChanges
1.02026-01-23Initial skill for SwiftUI app setup
1.1
2026-01-24 | Update to context-aware approach (remove file-parsing/Q&A). Skill references conversation context instead of asking questions or accepting file paths. |

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 fosmvvm-swiftui-app-setup-1776420040 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 fosmvvm-swiftui-app-setup-1776420040 技能

通过命令行安装

skillhub install fosmvvm-swiftui-app-setup-1776420040

下载

⬇ 下载 fosmvvm-swiftui-app-setup v2.0.6(免费)

文件大小: 8.46 KB | 发布时间: 2026-4-17 20:21

v2.0.6 最新 2026-4-17 20:21
Initial ClawHub release

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部