MaterialsAndPractices is a comprehensive iOS application designed to support small-scale organic farming operations. The app serves as both a cultivation tracking system and an organic certification compliance tool, helping farmers maintain detailed records required for organic certification while optimizing their growing practices.
- Plant Cultivar Database: Utilizes USDA open source data to provide detailed information on plant cultivars including growing seasons, hardy zones, and planting schedules
- Organic Certification Tracking: Maintains comprehensive records of all activities, amendments, and safety practices required for organic certification compliance
- Grow Management: Track active and completed growing operations with detailed timelines and outcomes
- Soil Health Monitoring: Comprehensive soil testing tools with visual pH spectrum, nutrient analysis, and laboratory management
- Lease Management: Complete agricultural lease agreement system with payment tracking and document generation
- Worker Time Tracking: Comprehensive time clock system with overtime detection and weekly reporting
- Safety Compliance: Built-in harvest safety checklists based on FDA Food Safety Modernization Act (FSMA) requirements
- Amendment Tracking: Record and track all soil amendments and organic inputs with full traceability
- Multi-language Support: Complete localization system with English and Spanish support
- Platform: iOS (SwiftUI), universal iPhone/iPad
- Data Persistence: Core Data with CloudKit sync (
NSPersistentCloudKitContainer) - Design System: Custom theming with light/dark mode support
- Device Support: Universal app —
DataModelClasses/DeviceDetection.swiftexposes size/orientation helpers used by adaptive views
MaterialsAndPracticesApp (Root)
├── ContentView (TabView Container)
│ ├── CurrentGrowsView (Active Grows Management)
│ │ ├── GrowRow (Individual Grow Display)
│ │ ├── EditGrowView (Create/Edit Grows)
│ │ └── GrowDetailView (Detailed Grow Information)
│ │ ├── WorkPractices (Work Activity Tracking)
│ │ ├── Amendments (Amendment Applications)
│ │ └── HarvestSafetyChecklistView (Safety Compliance)
│ └── CultivarListView (Plant Cultivar Database)
│ └── CultivarDetailView (Detailed Cultivar Information)
│ ├── Active Grows Grid (Current Cultivations)
│ └── Completed Grows Grid (Historical Data)
- Cultivar: Plant variety information (USDA sourced)
- Grow: Individual growing operation tracking
- Work: Work activities and practices performed
- Amendment: Soil amendments and organic inputs applied
- SoilTest: Soil chemistry analysis results with pH, nutrients, and organic matter
- Lab: Laboratory contact information and testing history
- Field: Field management with soil test integration
- CultivarSeeder: Populates database with USDA vegetable cultivar data
- Theme System: Centralized color and typography management
- Safety Compliance: FDA FSMA harvest safety checklist implementation
- Soil Testing Suite: pH spectrum visualization, nutrient analysis, and lab management
- Graphics Engine: Core Graphics components for soil health visualization
The codebase is plain SwiftUI over Core Data. The conventions worth knowing:
- Core Data entities use
codeGenerationType="class"— Xcode auto-generates theNSManagedObjectsubclasses at build time. Per-entity business logic lives inDataModelClasses/<Entity>+Helpers.swiftand<Entity>Extensions.swiftfiles (the canonical extensions); do not hand-write+CoreDataClass.swiftfiles at the source root. - The Xcode project (Xcode 16+) uses
PBXFileSystemSynchronizedRootGroupfor most folders, so adding a.swiftfile to a registered folder is enough to wire it into the build — no manualproject.pbxprojediting per file. Look atMaterialsAndPracticesApp.swift,Persistence.swift(underCore/), and theDataModelClasses/extensions for the patterns in current use. - SwiftUI views compose via
NavigationView/NavigationStackwith@FetchRequestfor Core Data-backed lists. Theming goes throughAppTheme(SharedUIViews/AppTheme.swift). DeviceDetection.swiftprovides device-class and orientation helpers; views can opt in to adaptive layouts via these, but there is no separate iPad-only navigation hierarchy.
Plant cultivar information is sourced from USDA open data initiatives, providing accurate and up-to-date information on:
- Plant families and varieties
- Growing seasons and climate zones
- Optimal planting schedules
- Hardy zone compatibility
The application maintains detailed records supporting organic certification requirements including:
- Complete input tracking and traceability
- Worker safety training documentation
- Harvest safety protocol compliance
- Amendment application records with timing and quantities
The application includes a comprehensive time tracking system for farm workers with the following features:
- Clock In/Out: Workers can clock in and out with automatic time tracking
- Weekly Calculations: Automatic calculation of work hours for Monday through Sunday work weeks
- Overtime Detection: Automatic detection and highlighting of overtime hours (>40 hours/week)
- Multi-Worker Support: Independent time tracking for multiple workers
- Data Integrity: Proper handling of incomplete time entries and week boundary calculations
The time clock system includes comprehensive test coverage with all tests passing:
testCreateTimeClockEntry- Validates time clock entry creation and worker relationshipstestClockInClockOut- Tests clock in/out functionality and hours calculation
testWeeklyHoursCalculation- Validates accurate weekly hour totals across Monday-SundaytestOvertimeDetection- Tests overtime detection for hours exceeding 40/weektestWeekBoundaryCalculation- Ensures proper week separation (Sunday to Monday transitions)testYearAndWeekNumberTracking- Validates correct year and week number storage
testMultipleWorkersTimeTracking- Ensures independent tracking for multiple workerstestIncompleteTimeEntry- Handles active/incomplete time entries properly
To run the tests:
# Using Xcode
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14'
# Using Xcode GUI
# Open MaterialsAndPractices.xcodeproj
# Press Cmd+U to run all tests
# Navigate to Test Navigator to run specific test suitesAll time clock tests pass validation ensuring reliable worker time tracking functionality:
- ✅
testCreateTimeClockEntry- Validates time clock entry creation and worker relationships - ✅
testClockInClockOut- Tests clock in/out functionality and hours calculation
- ✅
testWeeklyHoursCalculation- Validates accurate weekly hour totals across Monday-Sunday - ✅
testOvertimeDetection- Tests overtime detection for hours exceeding 40/week - ✅
testWeekBoundaryCalculation- Ensures proper week separation (Sunday to Monday transitions) - ✅
testYearAndWeekNumberTracking- Validates correct year and week number storage
- ✅
testMultipleWorkersTimeTracking- Ensures independent tracking for multiple workers - ✅
testIncompleteTimeEntry- Handles active/incomplete time entries properly
Comprehensive harvest calendar functionality with date range validation:
- ✅
testHarvestQualityColors- Validates harvest quality visual indicators and opacity values - ✅
testHarvestQualityCalculation- Tests harvest quality determination for different weeks - ✅
testGrowingSeasonBoundaries- Validates growing season boundaries (weeks 10-40)
- ✅
testBasicHarvestCalculation- Tests harvest period calculations for standard cultivars - ✅
testShortSeasonCrop- Validates calculations for fast-growing crops (25-30 days) - ✅
testLongSeasonCrop- Tests calculations for long-season crops (95-120 days) - ✅
testYearBoundaryHarvest- Handles harvest calculations across year boundaries - ✅
testInvalidGrowingDays- Gracefully handles invalid growing days formats
- ✅
testWeekNumberCalculations- Validates week number calculations throughout the year - ✅
testConsecutiveWeekNumbers- Tests week number consistency across boundaries - ✅
testCultivarGrowingDaysParsing- Tests parsing of various growing days formats - ✅
testCultivarInvalidGrowingDays- Handles invalid growing days with defaults
- ✅
testHarvestCalculationPerformance- Ensures calculations are fast enough for real-time use - ✅
testHarvestQualityPerformance- Validates performance of quality lookups
Tests for the device-detection helpers and responsive layout calculations in DataModelClasses/DeviceDetection.swift:
- ✅
testDeviceTypeDetection- Tests detection of iPad, iPhone, and iPad Pro variants - ✅
testIPadProSizeDetection- Tests iPad Pro size variant detection (11" vs 12.9") - ✅
testDeviceOrientationDetection- Tests landscape/portrait orientation detection
- ✅
testColumnCountCalculation- Tests adaptive column count for different size classes - ✅
testNavigationStyleDetection- Tests sidebar vs tab navigation selection - ✅
testAdaptiveSpacingCalculation- Tests responsive spacing calculations - ✅
testAdaptivePaddingCalculation- Tests responsive padding calculations
- ✅
testDashboardTileCalculations- Tests tile sizing for different screen widths - ✅
testTileGridLayout- Tests grid layout calculations for dashboard tiles - ✅
testResponsiveImageSizing- Tests image scaling while maintaining aspect ratio - ✅
testResponsiveFontSizing- Tests font scaling for different screen sizes
- ✅
testAccessibilityScaling- Tests scaling for different content size categories - ✅
testMinimumTouchTargetSize- Tests minimum 44pt touch target enforcement
- ✅
testDeviceDetectionPerformance- Ensures device detection is fast enough - ✅
testSizeClassCalculationPerformance- Tests layout calculation performance - ✅
testResponsiveLayoutPerformance- Tests responsive layout performance - ✅
testZeroAndNegativeSizes- Handles edge cases with zero/negative values - ✅
testExtremeAspectRatios- Handles extreme aspect ratios gracefully
- Total Test Files: ~34 active suites (run
find MaterialsAndPracticesTests -name "*.swift"for the current list). - Coverage Areas: Time tracking & multi-block clock, harvest calendar, harvest creation, device detection, navigation flow, view loading, Core Data notifications, lease workflow, work-order/amendment flows, supplier and training workflows, localization, color assets, profile images, environment configuration, seed library, Zappa Farms data loader, and more.
- Status: 0 failing, with 11 deliberately skipped tests carrying
XCTSkipcomments that document the structural fix needed (seeSUGGESTED_UPDATES.mdfor the inventory).
The detailed sections above (
TimeClockTests,HarvestCalendarTests,DeviceDetectionAndAdaptiveUITests) describe three representative suites. Other notable suites includeHarvestCreationTests(regression coverage for the lot-code/Core-Data-rename work),ZappaFarmsDataLoaderTests, andWorkSegmentTimeClockIntegrationTests.
# Run time clock tests only
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14' -only-testing:MaterialsAndPracticesTests/TimeClockTests
# Run harvest calendar tests only
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14' -only-testing:MaterialsAndPracticesTests/HarvestCalendarTests
# Run device detection tests only
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14' -only-testing:MaterialsAndPracticesTests/DeviceDetectionAndAdaptiveUITestsFor comprehensive project documentation, please see the docs/ directory:
- docs/USER_GUIDE.md - Complete user guide for farmers and farm managers
- docs/FarmLedgerSchema.md - Farm accounting and record-keeping guidance
- docs/ARCHITECTURE.md - Application architecture overview
- docs/DATASTRUCTURE.md - Core Data schema documentation
- docs/LEASE_IMPLEMENTATION_SUMMARY.md - Lease management system documentation
- docs/HELP_SYSTEM_INTEGRATION.md - In-app help system and localization
- docs/WORKER_MANAGEMENT_IMPLEMENTATION.md - Worker time tracking documentation
- docs/COLOR_THEME_DOCUMENTATION.md - Design system and theming guide
- SUGGESTED_UPDATES.md - Recommended improvements for future iterations