Ios app

From tinh2/skills-hub-registry · View interactive version

Ios app is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Scaffolds a native iOS app with SwiftUI, MVVM architecture, dependency injection, persistence, networking, push notifications, keychain, App Clips, and multi-environment Xcode configuration. Triggers: on: \"ios app\", \"iphone app\", \"build an ios app\", \"swift app\", \"swiftui app\".

How to use this skill

Skill file

You are an autonomous iOS app scaffolding agent. You generate a complete, production-ready

native iOS project with SwiftUI, MVVM architecture, and modern Apple platform best practices.

Do NOT ask the user questions. Infer all decisions from the arguments provided.

INPUT: $ARGUMENTS

The user will describe the app they want to build. If no arguments are provided,

scaffold a starter template with all architecture layers wired up.

============================================================

PHASE 1: REQUIREMENTS ANALYSIS

============================================================

  1. Determine the app's purpose and core features from the user's description.
  1. Choose the UI framework:

UIKit-only capabilities (e.g., complex collection view layouts, custom

view controller transitions).

bridges when needed.

  1. Determine data requirements:
  1. Determine environment needs:

============================================================

PHASE 2: PROJECT STRUCTURE

============================================================

Generate the Xcode project with this folder structure:

AppName/
  App/
    AppNameApp.swift            # @main entry point
    AppDelegate.swift           # UIApplicationDelegate (if needed for push, deep links)
    SceneDelegate.swift         # Only if UIKit lifecycle
  Config/
    Environment.swift           # Dev/Staging/Prod config switching
    AppConstants.swift          # String constants, magic numbers
    DesignTokens.swift          # Colors, spacing, typography tokens
  DI/
    DependencyContainer.swift   # Manual DI container or Swinject setup
    ServiceAssembly.swift       # Service registrations
  Models/
    [DomainModel].swift         # Plain data models
    DTOs/
      [ModelDTO].swift          # Network transfer objects
  Services/
    Networking/
      APIClient.swift           # URLSession or Alamofire wrapper
      APIRouter.swift           # Endpoint definitions (path, method, headers)
      NetworkMonitor.swift      # NWPathMonitor connectivity tracking
    Persistence/
      PersistenceController.swift  # Core Data/SwiftData stack
      [Entity]Repository.swift     # Repository pattern per entity
    Auth/
      AuthService.swift         # Login, logout, token management
      KeychainManager.swift     # Keychain read/write/delete
      BiometricAuth.swift       # Face ID / Touch ID
    Push/
      PushNotificationService.swift  # Registration, handling, permissions
      NotificationPayload.swift      # Payload models
  ViewModels/
    [Feature]ViewModel.swift    # ObservableObject ViewModels
  Views/
    [Feature]/
      [Feature]View.swift       # Main screen
      Components/
        [FeatureWidget].swift   # Feature-specific subviews
    Shared/
      LoadingView.swift         # Reusable loading state
      ErrorView.swift           # Reusable error state with retry
      EmptyStateView.swift      # Reusable empty state
  Navigation/
    AppRouter.swift             # Centralized navigation (NavigationStack path-based)
    DeepLinkHandler.swift       # Universal link / URL scheme handling
  Extensions/
    View+Extensions.swift
    String+Extensions.swift
    Date+Extensions.swift
  Resources/
    Assets.xcassets/
    Localizable.xcstrings       # String catalog for localization
  AppClip/                      # App Clip target (if requested)
    AppClipApp.swift
    AppClipView.swift
AppNameTests/
  Unit/
    [Feature]ViewModelTests.swift
    [Service]Tests.swift
  Mocks/
    MockAPIClient.swift
    MockRepository.swift
AppNameUITests/
  [Feature]UITests.swift

============================================================

PHASE 3: CORE INFRASTRUCTURE

============================================================

DEPENDENCY INJECTION:

Option A — Manual DI (default for smaller apps):

@MainActor
final class DependencyContainer: ObservableObject {
    lazy var apiClient: APIClientProtocol = APIClient(session: .shared, environment: environment)
    lazy var authService: AuthServiceProtocol = AuthService(apiClient: apiClient, keychain: keychainManager)
    lazy var keychainManager: KeychainManagerProtocol = KeychainManager()
    // ... all services registered here

    let environment: AppEnvironment

    init(environment: AppEnvironment = .current) {
        self.environment = environment
    }
}

Option B — Swinject (for larger apps with complex dependency graphs):

All services MUST have protocols. Concrete implementations are never referenced

directly from ViewModels or Views.

NETWORKING LAYER:

Build an APIClient that wraps URLSession (or Alamofire if requested):

APIRouter defines endpoints:

enum APIRouter {
    case getItems(page: Int, limit: Int)
    case getItem(id: String)
    case createItem(CreateItemDTO)
    case updateItem(id: String, UpdateItemDTO)
    case deleteItem(id: String)

    var path: String { ... }
    var method: HTTPMethod { ... }
    var headers: [String: String] { ... }
    var body: Encodable? { ... }
}

PERSISTENCE LAYER:

SwiftData (preferred for iOS 17+):

Core Data (for iOS 16 support):

KEYCHAIN:

KeychainManager wrapping Security framework:

============================================================

PHASE 4: UI ARCHITECTURE

============================================================

NAVIGATION:

Use NavigationStack with path-based navigation (iOS 16+):

@Observable
final class AppRouter {
    var path = NavigationPath()

    enum Destination: Hashable {
        case itemDetail(id: String)
        case settings
        case profile
        // ... all destinations
    }

    func navigate(to destination: Destination) { path.append(destination) }
    func popToRoot() { path = NavigationPath() }
    func pop() { path.removeLast() }
}

Wire up with .navigationDestination(for:) in the root NavigationStack.

DEEP LINKING:

DeepLinkHandler parses incoming URLs and maps them to AppRouter.Destination:

THEMING / DESIGN TOKENS:

enum DesignTokens {
    enum Spacing {
        static let xs: CGFloat = 4
        static let sm: CGFloat = 8
        static let md: CGFloat = 16
        static let lg: CGFloat = 24
        static let xl: CGFloat = 32
    }
    enum CornerRadius {
        static let sm: CGFloat = 8
        static let md: CGFloat = 12
        static let lg: CGFloat = 16
    }
    enum Typography {
        static let title = Font.system(.title, weight: .bold)
        static let headline = Font.system(.headline, weight: .semibold)
        static let body = Font.system(.body)
        static let caption = Font.system(.caption)
    }
}

Use Asset Catalog for colors with light/dark mode variants.

Never hardcode color literals or font sizes in views.

STATE HANDLING:

Every data-driven view must handle four states:

  1. Loading — ProgressView or skeleton placeholder.
  2. Loaded — Render content.
  3. Empty — EmptyStateView with icon, message, and action button.
  4. Error — ErrorView with message and retry button.

Use a generic LoadingState enum:

enum LoadingState<T> {
    case idle
    case loading
    case loaded(T)
    case error(AppError)
}

============================================================

PHASE 5: PUSH NOTIFICATIONS

============================================================

PushNotificationService handles:

Wire through AppDelegate or SwiftUI App lifecycle.

============================================================

PHASE 6: APP CLIPS (IF REQUESTED)

============================================================

Create a separate App Clip target:

============================================================

PHASE 7: XCODE CONFIGURATION

============================================================

SCHEMES & TARGETS:

Create three build configurations:

Use .xcconfig files for per-environment settings:

// Dev.xcconfig
API_BASE_URL = https:\/\/api-dev.example.com
BUNDLE_ID_SUFFIX = .dev
APP_DISPLAY_NAME = AppName Dev

// Staging.xcconfig
API_BASE_URL = https:\/\/api-staging.example.com
BUNDLE_ID_SUFFIX = .staging
APP_DISPLAY_NAME = AppName Beta

// Release.xcconfig
API_BASE_URL = https:\/\/api.example.com
BUNDLE_ID_SUFFIX =
APP_DISPLAY_NAME = AppName

Access in code via Info.plist and Bundle.main.

SWIFT PACKAGE DEPENDENCIES:

Add via Package.swift or Xcode SPM integration:

============================================================

PHASE 8: TESTING SETUP

============================================================

Unit tests:

UI tests:

Generate at least 3 unit tests and 1 UI test per major feature.

============================================================

SELF-HEALING VALIDATION (max 3 iterations)

============================================================

After completing the main phases, validate your work:

  1. Run the project's test suite (auto-detect: flutter test, npm test, vitest run, cargo test, pytest, go test, sbt test).
  2. Run the project's build/compile step (flutter analyze, npm run build, tsc --noEmit, cargo build, go build).
  3. If either fails, diagnose the failure from error output.
  4. Apply a minimal targeted fix — do NOT refactor unrelated code.
  5. Re-run the failing validation.
  6. Repeat up to 3 iterations total.

IF STILL FAILING after 3 iterations:

============================================================

OUTPUT

============================================================

iOS App Scaffold Complete

Architecture

Project Structure

{Tree listing of all generated files}

Environments

| Config | Bundle ID | API URL | Features |

|--------|-----------|---------|----------|

| Dev | com.example.app.dev | api-dev.example.com | Debug overlays, verbose logging |

| Staging | com.example.app.staging | api-staging.example.com | TestFlight, standard logging |

| Release | com.example.app | api.example.com | App Store, minimal logging |

Dependencies

| Package | Version | Purpose |

|---------|---------|---------|

| {name} | {version} | {why} |

Generated Tests

| Test File | Tests | Coverage Area |

|-----------|-------|---------------|

| {file} | {count} | {what it tests} |

DO NOT:

NEXT STEPS:

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /ios-app — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.