Home - Tai-Kimura/SwiftJsonUI GitHub Wiki
The JSON-driven UI framework for iOS that now supports both UIKit and SwiftUI. Build native iOS interfaces using simple JSON definitions and automatic code generation.
- 🎨 ColorManager: Centralized color management with automatic extraction from JSON layouts
- 🔤 StringManager: Automatic string extraction and localization support
- 📁 ResourceManager Directory: Generated Swift code for colors and strings
- 🔍 Undefined Resource Tracking: Track and manage undefined colors and strings
- 🔄 SwiftJsonUIConfiguration Integration: Improved colorProvider priority handling
- 🏗️ Section-Based Architecture: Redesigned CollectionDataSource for SwiftUI
- 📊 Flexible Layouts: Different column counts and cell types per section
- 🔄 Full Mode Support: Dynamic and Static modes work identically
-
↔️ Scroll Options: Horizontal/vertical with indicator controls
-
🔄 Binding Properties: Use
@propertyNamesyntax for two-way bindings -
📝 JSON Binding: Bind to ViewModel with
@{propertyName}
-
🎯 SwiftUI Custom Components:
sjui g convertergenerates custom components - 📁 Three Files Generated: Swift component, Ruby converter, and Dynamic adapter
- 🔥 Hot Reload Support: Custom components work with hot reload
Write once in JSON, deploy to both UIKit and SwiftUI:
- Unified JSON Format - Single definition works for both platforms
- Automatic MVVM Generation - ViewModels and data models created automatically for SwiftUI
- Smart Mode Switching - ViewSwitcher automatically optimizes for Debug/Release builds
- Full Feature Parity - All components work seamlessly across both platforms
-
Restructured for Clarity -
uikitandswiftuifolders clearly separate implementations -
Enhanced CLI Tools -
sjui_toolsreplacesbinding_builderwith expanded capabilities - Improved Performance - Dynamic mode for development, static mode for production
- iOS 16.0+
- Swift 5.8+
- Xcode 14.0+
- Node.js (for development tools)
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/Tai-Kimura/SwiftJsonUI.git", from: "7.2.0")
]# One-line installer (recommended)
curl -fsSL https://raw.githubusercontent.com/Tai-Kimura/SwiftJsonUI/master/installer/bootstrap.sh | bash
# Or install specific version
curl -fsSL https://raw.githubusercontent.com/Tai-Kimura/SwiftJsonUI/master/installer/bootstrap.sh | bash -s -- -v 7.0.0cd sjui_tools
# Choose your platform
sjui_tools/bin/sjui init --mode uikit # UIKit only
sjui_tools/bin/sjui init --mode swiftui # SwiftUI only
sjui_tools/bin/sjui init --mode all # Both platforms
# Setup project structure
sjui_tools/bin/sjui setupFor SwiftUI:
sjui_tools/bin/sjui g view HomeView --rootThis generates:
-
View/HomeView/HomeViewView.swift- Your editable view -
View/HomeView/HomeViewGeneratedView.swift- Auto-generated view -
ViewModel/HomeViewViewModel.swift- ViewModel with business logic -
Data/HomeViewData.swift- Data model -
Layouts/home_view.json- JSON layout definition
For UIKit:
sjui_tools/bin/sjui g view Home --rootThis generates:
-
View/Home/HomeViewController.swift- View controller -
Layouts/home.json- JSON layout -
Bindings/HomeBinding.swift- Generated bindings (after build)
Edit Layouts/home_view.json:
{
"type": "SafeAreaView",
"id": "main_container",
"background": "#FFFFFF",
"child": [
{
"type": "Label",
"id": "welcome_text",
"text": "Welcome to SwiftJsonUI 7.0!",
"fontSize": 24,
"fontColor": "#000000",
"textAlign": "Center"
},
{
"type": "Button",
"id": "get_started",
"text": "Get Started",
"onClick": "handleGetStarted",
"background": "#007AFF",
"fontColor": "#FFFFFF",
"cornerRadius": 8,
"padding": [12, 24]
}
]
}# Generate bindings/views
sjui_tools/bin/sjui build
# Start hot reload for instant updates
sjui_tools/bin/sjui hotload listenYourApp/
├── Layouts/ # JSON definitions
├── View/ # SwiftUI views
│ └── HomeView/
│ ├── HomeViewView.swift # Editable
│ └── HomeViewGeneratedView.swift # Auto-generated
├── ViewModel/ # ViewModels
└── Data/ # Data models
YourApp/
├── Layouts/ # JSON definitions
├── View/ # ViewControllers
├── Bindings/ # Generated bindings
└── Core/ # Base classes
See your changes instantly without recompiling:
# Start the server
sjui_tools/bin/sjui hotload listen
# Edit any JSON file - changes appear immediately
# Works with both UIKit and SwiftUIAll components work across both platforms:
| Component | UIKit | SwiftUI |
|---|---|---|
| Label | ✅ Full | ✅ Full |
| Button | ✅ Full | ✅ Full |
| TextField | ✅ Full | ✅ Full |
| Image | ✅ Full | ✅ Full |
| ScrollView | ✅ Full | ✅ Full |
| Table/List | ✅ Full | |
| Collection | ✅ Full | ✅ Full |
| And 20+ more... |
{
"type": "View",
"id": "my_view",
"width": "matchParent",
"height": "wrapContent",
"child": [...]
}{
"data": [
{
"name": "userName",
"class": "String",
"defaultValue": "Guest"
}
],
"child": [
{
"type": "Label",
"text": "@{userName}" // Automatic binding
}
]
}Create reusable styles in Styles/:
{
"background": "#007AFF",
"fontColor": "#FFFFFF",
"cornerRadius": 8,
"padding": 12
}Use in layouts:
{
"type": "Button",
"style": "primary_button",
"text": "Click Me"
}# Project setup
sjui init [--mode uikit|swiftui|all] # Initialize project
sjui setup # Create structure
# View generation
sjui g view <name> [--root] # Generate view
sjui g collection <View>/<Cell> # Generate collection cell
sjui g partial <name> # Generate reusable partial
sjui g converter <name> [options] # Generate custom component
sjui d view <name> # Delete view
# Building
sjui build [--mode uikit|swiftui|all] # Generate code
sjui build --clean # Clean cache and rebuild
# Hot reload
sjui hotload listen # Start server
sjui hotload stop # Stop server
# Utilities
sjui convert to-group [--force] # Xcode 16 compatibilityAutomatic optimization based on build configuration:
- DEBUG: Dynamic mode - reads JSON at runtime for rapid development
- RELEASE: Static mode - uses generated code for optimal performance
// Automatic in generated code
ViewSwitcher(
isDynamicMode: isDynamicMode,
dynamicView: { DynamicComponent(...) },
staticView: { YourGeneratedView(...) }
){
"include": "header",
"variables": {
"title": "Welcome, @{userName}"
}
}{
"type": "Button",
"onClick": "handleTap", // Method binding
"onLongPress": {
"closure": "handleLongPress",
"duration": 0.5
}
}# Generate collection cell for UITableView/UICollectionView
sjui g collection ProductList/ProductCell
# This creates:
# - View/ProductList/Collection/ProductCell.swift
# - Layouts/product_cell.json# Generate a reusable partial component
sjui g partial header
# Use in your layouts:
{
"include": "header"
}See Include-System for detailed documentation on using partials and includes.
Customize default values for all components:
class UIViewCreator: SJUIViewCreator {
class func prepare() {
defaultFont = "System"
defaultFontSize = 14.0
defaultFontColor = UIColor.label
// Add your customizations
}
}sjui.config.json:
{
"project_name": "YourApp",
"mode": "swiftui", // or "uikit" or "all"
"layouts_directory_name": "Layouts",
"styles_directory_name": "Styles"
}- All-Attributes - Complete attribute reference for all components
- View Types - All available component types
- Attributes - Core attribute system
- Data-Binding - Data binding system, expressions, and binding groups
- Include-System - Component composition and reusability
- Advanced-Features - Event handling, gestures, shadows, and more
- Converter-Command - Generate custom SwiftUI components
- VSCode-Extension - Official VSCode extension with autocomplete and templates
- External-Libraries-Integration - Integrate third-party libraries
- SwiftJsonUI-7.2.0-Release-Notes - Latest release notes
- SwiftJsonUI-7.1.2-Release-Notes - Collection improvements
- SwiftJsonUI-7.1.1-Release-Notes - Binding properties release
- SwiftJsonUI-7.1.0-Release-Notes - Custom components release
- SwiftJsonUI-7.0.0-Changes - Detailed changelog for 7.0
- Component docs - Label, Button, TextField, etc.
Complete demo project showing SwiftJsonUI setup:
git clone https://github.com/Tai-Kimura/bindingTestApp.git
cd bindingTestApp
./bindingTestApp/clear_and_setup.shNo code changes required - 7.1.0 is fully backward compatible with performance improvements.
- Update Package.swift to version 7.1.0
- Rename
binding_builderreferences tosjui_tools - Update
bindingfolder references touikit - Reinstall CLI tools with latest version
- Choose your platform mode with
sjui init --mode
- Choose Your Platform - Start with either UIKit or SwiftUI, add the other later if needed
- Use Hot Reload - Dramatically speeds up UI development
- Organize with Subdirectories - Group related layouts by feature
- Create Reusable Styles - Define once, use everywhere
-
Leverage Data Binding - Use
@{}syntax for automatic updates
Command not found:
# Ensure you're in sjui_tools directory
cd sjui_tools
# Make executable
chmod +x bin/sjuiHot reload not working:
# Check Node.js installation
node --version
# Restart server
sjui hotload stop && sjui hotload listenBuild errors:
# Clean and rebuild
sjui build --clean
# Check JSON syntax
sjui validateThe Android counterpart to SwiftJsonUI, supporting Android Views, Jetpack Compose, and XML layouts:
- Repository: KotlinJsonUI
- Wiki: KotlinJsonUI Documentation
- Features: Same JSON format, cross-platform UI development
- XML Support: Component and Attribute Mappings
- Issues: GitHub Issues
- Wiki: Documentation
- Examples: Sample Projects
SwiftJsonUI is available under the MIT license.