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:
backgroundColortextColortintColorborderColorhighlightColor- And all other color-related attributes
Intelligent Color Naming
When hex colors are found in layouts, ColorManager generates descriptive names based on RGB values:
#007AFF→blue_007AFF#FF5733→orange_red_FF5733#F2F2F7→pale_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:
textproperties in all componentspartial_attributes.range.textfor attributed text- Any text content in layouts
String Classification
- Defined strings: Snake_case keys like
welcome_messageare treated as localization keys - Undefined strings: Direct text like "Welcome!" is extracted for localization
Generated Files
strings.json- String definitions with translations.stringsfiles - Native iOS localization filesStringManager.swift- Type-safe string accessors
Localization Workflow
- Strings are automatically extracted during build
- Missing translations are marked with
NOT_IMPLEMENTED_YET - Update
strings.jsonwith translations - Build regenerates
.stringsfiles
🔧 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:
- Custom
colorProvider - ColorManager definitions
- 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:
- Extract all colors and strings from JSON layouts
- Update resource JSON files
- Generate Swift accessor classes
- 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:
- Update to SwiftJsonUI 7.2.0
- Add
resource_manager_directoryto config - Run
sjui buildto generate resources - 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
- ColorManager - Detailed color management guide
- StringManager - String extraction and localization
- SwiftJsonUIConfiguration - Configuration options