Skip to content

rework project generation and adoption#8

Merged
nickhart merged 2 commits intomainfrom
fix_swiftlint_check
Oct 18, 2025
Merged

rework project generation and adoption#8
nickhart merged 2 commits intomainfrom
fix_swiftlint_check

Conversation

@nickhart
Copy link
Owner

Summary

Completely redesigned how we use this template project. Now using Xcode project templates is the default workflow:

  1. create a new repo from this template repo
  2. clone the new repo
  3. create a new Xcode project and save it in the cloned repo uncheck the "create git repository" option
  4. run ./scripts/setup.sh --project-name YourApp
  5. commit the project to git

It is still possible to generate a simple project as well, which is what the CI will do if it does not find a configured project.yml.

Changes

  • moved old template files into their "real" locations, updated to use placeholder variables, and removed old templates
  • revamped setup.sh to update files in-place and replace placeholder variables with real values
  • updated documentation

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Configuration change
  • ♻️ Code refactoring
  • 🧪 Test improvements
  • 🔒 Security update

Testing

  • Unit tests pass (./scripts/test.sh)
  • UI tests pass (./scripts/test.sh --ui)
  • Manual testing completed
  • Code builds successfully (./scripts/build.sh)
  • Linting passes (./scripts/lint.sh)
  • Formatting is correct (./scripts/format.sh)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

nickhart and others added 2 commits October 17, 2025 20:35
Major architectural simplification that eliminates template processing complexity
and unifies CI workflows for both template and generated projects.

## Changes

### Eliminated Complexity
- Removed templates/ directory entirely
- Deleted template-validation.yml (redundant)
- Replaced complex template processing with simple in-place sed replacement
- setup.sh: 1,244 lines → 368 lines (70% reduction)
- CI workflow: 217 lines → 95 lines (56% reduction)

### New Architecture
- Files now live in their final locations with {{PLACEHOLDERS}}
- MyProject/ is placeholder directory (gets renamed during setup)
- Single unified ci.yml that auto-configures when needed
- Same workflow works for template repo and generated projects

### Improvements
- Simpler mental model: files are where they live
- No template copying, just in-place replacement
- Can run setup.sh on template repo immediately
- CI detects unconfigured state and auto-runs setup
- Local and CI use identical scripts (no duplication)

### Fixed
- Pre-commit hook now works correctly from .git/hooks/
- Uses git rev-parse to find repo root reliably
- Sources _helpers.sh from correct location

## Benefits

1. **Easier to understand**: See actual project structure immediately
2. **Easier to maintain**: One CI workflow instead of two
3. **Faster setup**: Simple sed replacement vs template processing
4. **Same CI everywhere**: Template and generated repos use identical workflow
5. **Better DX**: Preview project structure before setup

Co-Authored-By: Claude <noreply@anthropic.com>
Implements two setup modes to support different workflows:
1. ADOPT mode (primary): Integrate with existing Xcode projects
2. GENERATE mode (secondary): Create minimal project for quick starts

## Key Changes

### Removed
- MyProject/, MyProjectTests/, MyProjectUITests/ placeholder directories
- No more checked-in placeholder code
- Removed rename_directories() function (obsolete)

### Added Setup Modes

**ADOPT Mode (Primary Workflow)**
- Detects existing .xcodeproj automatically
- Configures tooling around existing project structure
- Respects Xcode-generated code and templates
- Optional directory structure creation with --structure flag

**GENERATE Mode (Quick Start)**
- Creates minimal UIKit project on-demand
- Generates AppDelegate, SceneDelegate, ViewController
- Creates test targets with swift-testing
- Configurable structure: mvvm, clean, or none

### New setup.sh Features
- `--generate-minimal`: Force generation mode
- `--structure <type>`: Choose directory structure (mvvm/clean/none)
- Auto-detection: Checks for .xcodeproj and chooses mode intelligently
- Helpful error messages when mode is ambiguous

### Functions Added
- `detect_project_mode()`: Auto-detect adopt vs generate
- `generate_minimal_project()`: Create minimal Swift files
- `create_directory_structure()`: Flexible structure creation
- `adopt_existing_project()`: Verify and configure existing project

### CI Updates
- Uses `--generate-minimal` flag for template testing
- Explicitly specifies `--structure mvvm` for clarity
- Better detection message (distinguishes template vs derived repos)

### Documentation Updates
- CLAUDE.md: Comprehensive dual-mode workflow documentation
- setup.sh: Enhanced help with examples for both modes
- Clear primary vs secondary workflow guidance

## Benefits

1. **Xcode-first workflow**: Use any Xcode template, add automation
2. **Flexibility**: Quick start still available with --generate-minimal
3. **No confusion**: No placeholder MyProject/ sitting in repo
4. **Testable template**: CI generates and validates automatically
5. **Clean repository**: Only config files, no placeholder code

## Migration

Users upgrading should:
- Old workflow still works with --generate-minimal flag
- New recommended workflow: Create in Xcode first, then adopt

Co-Authored-By: Claude <noreply@anthropic.com>
@nickhart nickhart enabled auto-merge October 18, 2025 05:05
@nickhart nickhart disabled auto-merge October 18, 2025 05:05
@nickhart nickhart merged commit fabb87d into main Oct 18, 2025
1 check failed
@nickhart nickhart deleted the fix_swiftlint_check branch October 18, 2025 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments