SwiftJsonUI 7.1.2 Release Notes - Tai-Kimura/SwiftJsonUI GitHub Wiki
SwiftJsonUI 7.1.2 Release Notes
Release Date
August 28, 2025
Overview
SwiftJsonUI 7.1.2 brings major improvements to the Collection component for SwiftUI, introducing section-based architecture, enhanced data binding, and full support for both Dynamic and Static modes.
✨ Major Improvements
1. CollectionDataSource Redesigned for SwiftUI
New Section-Based Architecture
The CollectionDataSource has been completely redesigned with a section-based approach:
New CollectionDataSection Class:
class CollectionDataSection {
var header: (viewName: String, data: [String: Any](/Tai-Kimura/SwiftJsonUI/wiki/String:-Any))?
var cells: (viewName: String, data: [String: Any](/Tai-Kimura/SwiftJsonUI/wiki/String:-Any))?
var footer: (viewName: String, data: [String: Any](/Tai-Kimura/SwiftJsonUI/wiki/String:-Any))?
var numberOfColumns: Int = 2
}
Benefits:
- ✅ One cell type can handle multiple data items
- ✅ Each section can have different column counts
- ✅ Separate header and footer views per section
- ✅ More flexible data management
Usage Example:
let dataSource = CollectionDataSource()
// Create sections with different configurations
let section1 = CollectionDataSection()
section1.cells = ("ProductCell", productData)
section1.numberOfColumns = 3
let section2 = CollectionDataSection()
section2.cells = ("CategoryCell", categoryData)
section2.numberOfColumns = 2
section2.header = ("SectionHeader", ["title": "Categories"](/Tai-Kimura/SwiftJsonUI/wiki/"title":-"Categories"))
dataSource.sections = [section1, section2]
2. Enhanced Static Mode (Code Generation)
Updated Collection Converter
The collection_converter.rb has been updated to support the new section architecture:
// Generated code example
ForEach(Array(viewModel.collectionDataSource.sections.enumerated()), id: \.offset) { index, section in
Section {
if let cells = section.cells?.data {
LazyVGrid(columns: columns, spacing: 10) {
ForEach(Array(cells.enumerated()), id: \.offset) { cellIndex, cellData in
buildCellView(section.cells?.viewName ?? "", cellData)
}
}
}
}
}
New Features:
- Optional chaining with
cells?.datafor safe access - Horizontal scroll support
- Scroll indicator visibility control
3. Dynamic Mode Collection Display Fix
Problem Solved
Collections were not displaying in Dynamic mode due to type mismatch.
Issue:
itemsproperty was defined as[String]- Could not accept binding strings like
"@{items1}"
Solution:
- Modified to accept both arrays and strings
- Proper binding resolution for Dynamic mode
4. Dynamic Mode CollectionConverter Implementation
Full Feature Support
The Dynamic mode converter now supports:
{
"type": "Collection",
"items": "@{collectionItems}",
"sections": [
{
"cells": "ProductCell",
"columns": 3
},
{
"cells": "CategoryCell",
"columns": 2,
"header": "SectionHeader"
}
],
"layout": "horizontal",
"showsHorizontalScrollIndicator": false,
"showsVerticalScrollIndicator": true
}
Features:
- Section attribute parsing
- Data retrieval from CollectionDataSource
- Per-section column configuration
- Horizontal layout support (
layout: "horizontal") - Scroll indicator visibility control
5. Multi-Section Testing Support
Enhanced Test Capabilities
Added support for complex multi-section layouts:
// Example: 3 sections with different column counts
multiSectionItems = [
Section(columns: 3, cells: "ProductCell"),
Section(columns: 2, cells: "UserCard"),
Section(columns: 4, cells: "IconCell")
]
Improvements:
- Different cell types per section
- Variable column counts (3, 2, 4 columns)
- Section-specific layouts
6. Debugging and Troubleshooting
Enhanced Debug Logging
Added comprehensive debugging support:
- FailableDecodable: Debug logs for decoding failures
- DynamicDecodingHelper: Component decode logging
- Collection-specific: Detailed error identification
Example Debug Output:
[Collection] Decoding component...
[Collection] Successfully decoded with items: @{items1}
[Collection] Sections count: 2
[Collection] Section 0: 3 columns, ProductCell
[Collection] Section 1: 2 columns, CategoryCell
📋 Technical Improvements
SwiftUI CollectionView Compatibility
- ✅ Native SwiftUI LazyVGrid/LazyHGrid support
- ✅ Proper GeometryReader usage for responsive layouts
- ✅ Smooth scrolling performance
Unified Behavior Across Modes
- ✅ Dynamic and Static modes work identically
- ✅ Same JSON structure for both modes
- ✅ Consistent rendering results
Layout Support
- ✅ Vertical scrolling (default)
- ✅ Horizontal scrolling with
layout: "horizontal" - ✅ Scroll indicator customization
- ✅ Adaptive column widths
Data Binding Flexibility
- ✅ Direct array binding
- ✅ ViewModel property binding with
@{propertyName} - ✅ Section-based data organization
- ✅ Dynamic cell type selection
🔄 Migration from 7.1.1
Update Package.swift
dependencies: [
.package(url: "https://github.com/Tai-Kimura/SwiftJsonUI.git", from: "7.1.2")
]
Update Collection Usage
Old Format (Still Supported):
{
"type": "Collection",
"items": ["item1", "item2"],
"columns": 2
}
New Format (Recommended):
{
"type": "Collection",
"items": "@{collectionData}",
"sections": [
{
"cells": "MyCell",
"columns": 3,
"header": "HeaderView",
"footer": "FooterView"
}
],
"showsVerticalScrollIndicator": false
}
💡 Usage Examples
Example 1: Product Grid
{
"type": "Collection",
"items": "@{products}",
"sections": [
{
"cells": "ProductCard",
"columns": 3
}
],
"padding": 16,
"spacing": 10
}
Example 2: Horizontal Category Scroll
{
"type": "Collection",
"items": "@{categories}",
"layout": "horizontal",
"sections": [
{
"cells": "CategoryChip",
"columns": 1
}
],
"showsHorizontalScrollIndicator": false,
"height": 50
}
Example 3: Multi-Section Layout
{
"type": "Collection",
"items": "@{mixedContent}",
"sections": [
{
"header": "FeaturedHeader",
"cells": "FeaturedCell",
"columns": 1
},
{
"header": "PopularHeader",
"cells": "GridCell",
"columns": 2
},
{
"cells": "CompactCell",
"columns": 4,
"footer": "LoadMoreFooter"
}
]
}
🐛 Bug Fixes
- Fixed Collection components not displaying in Dynamic mode
- Resolved type mismatch issues with items property
- Fixed horizontal scroll layout using HStack instead of VStack
- Corrected scroll indicator visibility attributes
- Fixed section data optional chaining in generated code
📚 Documentation Updates
- Updated Collection component documentation
- Added section-based layout examples
- Improved debugging guides
- Enhanced migration instructions
📬 Support
- Documentation: SwiftJsonUI Wiki
- Issues: GitHub Issues
- Examples: Collection Examples
SwiftJsonUI is developed and maintained by Tai Kimura