SwiftJsonUI 7.2.0 Release Notes - Tai-Kimura/SwiftJsonUI GitHub Wiki

SwiftJsonUI 7.2.0 Release Notes

Released: August 31, 2025

🎉 Major Features

SwiftJsonUI 7.2.0 introduces a comprehensive Resource Management System that automates the extraction, management, and generation of colors and strings from your JSON layout files.

🎨 ColorManager - Centralized Color Management

Overview

ColorManager automatically extracts color values from your JSON layouts and creates a centralized color management system that works seamlessly with both UIKit and SwiftUI.

Key Features

Automatic Color Extraction

The build process now automatically scans all JSON layout files and extracts color values from properties like:

  • backgroundColor
  • textColor
  • tintColor
  • borderColor
  • highlightColor
  • And all other color-related attributes

Intelligent Color Naming

When hex colors are found in layouts, ColorManager generates descriptive names based on RGB values:

  • #007AFFblue_007AFF
  • #FF5733orange_red_FF5733
  • #F2F2F7pale_gray_F2F2F7

Resource Files

colors.json - Define your app's color palette:

{
  "primary_blue": "#007AFF",
  "background_gray": "#F2F2F7",
  "text_primary": "#000000"
}

defined_colors.json - Track undefined colors for future definition:

{
  "#FF5733": "orange_red_FF5733",
  "#28A745": "green_28A745"
}

Generated Swift Code

ColorManager.swift is automatically generated with type-safe accessors:

// UIKit
view.backgroundColor = ColorManager.uikit.primaryBlue

// SwiftUI
Text("Hello")
    .foregroundColor(ColorManager.swiftui.primaryBlue)

Configuration

Enable ColorManager by setting resource_manager_directory in sjui.config.json:

{
  "resource_manager_directory": "ResourceManager"
}

🔤 StringManager - Localization Support

Overview

StringManager extracts text strings from JSON layouts and provides automatic localization support for multi-language apps.

Key Features

Automatic String Extraction

Extracts strings from:

  • text properties in all components
  • partial_attributes.range.text for attributed text
  • Any text content in layouts

String Classification

  • Defined strings: Snake_case keys like welcome_message are treated as localization keys
  • Undefined strings: Direct text like "Welcome!" is extracted for localization

Generated Files

  • strings.json - String definitions with translations
  • .strings files - Native iOS localization files
  • StringManager.swift - Type-safe string accessors

Localization Workflow

  1. Strings are automatically extracted during build
  2. Missing translations are marked with NOT_IMPLEMENTED_YET
  3. Update strings.json with translations
  4. Build regenerates .strings files

🔧 SwiftJsonUIConfiguration Improvements

Enhanced colorProvider Priority

The colorProvider in SwiftJsonUIConfiguration now has proper priority handling:

SwiftJsonUIConfiguration.shared.colorProvider = { colorName in
    // Your custom color resolution
    return MyColorPalette.color(for: colorName)
}

Priority order:

  1. Custom colorProvider
  2. ColorManager definitions
  3. System defaults

📁 Project Structure Updates

New Resource Management Structure

Project/
├── Layouts/
│   └── Resources/
│       ├── colors.json          # Color definitions
│       ├── defined_colors.json  # Undefined color tracking
│       ├── strings.json         # String definitions
│       └── .strings files       # iOS localization
├── ResourceManager/
│   ├── ColorManager.swift      # Generated color accessors
│   └── StringManager.swift     # Generated string accessors
└── sjui.config.json

🚀 How to Use

1. Update Configuration

Add to sjui.config.json:

{
  "resource_manager_directory": "ResourceManager"
}

2. Build Your Project

sjui build

The build process will:

  1. Extract all colors and strings from JSON layouts
  2. Update resource JSON files
  3. Generate Swift accessor classes
  4. Apply strings to localization files

3. Use in Code

Colors

// UIKit
label.textColor = ColorManager.uikit.textPrimary

// SwiftUI
Text("Hello")
    .foregroundColor(ColorManager.swiftui.textPrimary)

Strings

// UIKit
label.text = StringManager.welcomeMessage

// SwiftUI
Text(StringManager.welcomeMessage)

🔄 Migration from 7.1.x

7.2.0 is fully backward compatible. To enable new features:

  1. Update to SwiftJsonUI 7.2.0
  2. Add resource_manager_directory to config
  3. Run sjui build to generate resources
  4. Optionally migrate hardcoded colors/strings to use generated accessors

🐛 Bug Fixes

  • Fixed cache file paths for SwiftUI builds
  • Improved handling of color properties in dynamic components
  • Better error handling for malformed JSON files
  • Fixed duplicate property issues in generated code

📚 Documentation

🔗 Links