Skip to content

Conversation

@vididvidid
Copy link

Title

fix: Sanitize project names in iOS generators to support dashes

Description

This PR fixes Issue #23 where project names containing dashes (e.g., my-app) caused build failures in the generated iOS code.

The Problem

Objective-C class names cannot contain hyphens. When the Valdi CLI generates a project with a dash in the name, the compiler currently injects the raw string into @class and @interface declarations (e.g., test-valdiAppComponent), which causes syntax errors during the Xcode build process.

The Fix

I updated the iOS generator files to sanitize class names before they are written to the output files. I added .replacingOccurrences(of: "-", with: "_") in the following files to ensure valid Objective-C syntax:

  • compiler/compiler/Compiler/Sources/Generation/ObjC/ObjCCodeGenerator.swift
  • compiler/compiler/Compiler/Sources/Template/ObjCViewClassGenerator.swift
  • compiler/compiler/Compiler/Sources/ViewModels/ObjCModelGenerator.swift

With these changes, a project named my-app will correctly generate class names using underscores (e.g., my_appAppComponent) instead of dashes.

Related Issue

Fixes #23

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

Test Plan

Note on Environment: I am contributing from a Linux (WSL) environment and do not have access to Xcode to run the full valdi install ios build.

I verified the fix in the following ways:

  1. Logic Verification: I verified the Swift string replacement logic (replacingOccurrences) via a standalone Swift script to confirm it correctly converts kebab-case strings to snake_case.
  2. Compiler Tests: I attempted to run swift test locally, but I encountered unrelated dependency issues on Linux (specifically inside the Zip library, which seems to have strict typing issues on WSL). Since my changes are strictly limited to string sanitization in the iOS generators, I am relying on the CI (GitHub Actions) to verify that the full test suite passes on macOS.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

@Venuru
Copy link

Venuru commented Nov 28, 2025

Great fix! Thanks for improving the iOS generator to handle dashed project names.

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.

Project names with dashes don't build

2 participants