Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Sanitize class names in ObjC generator to allow dashes (fixes #23) #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vididvidid wants to merge 1 commit into Snapchat:main
base: main
Choose a base branch
Loading
from vididvidid:fix/sanitize-ios-class-names

Conversation

@vididvidid
Copy link

@vididvidid vididvidid commented Nov 23, 2025

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

Aareon, prabhatwbst, and 7kylor reacted with thumbs up emoji
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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Project names with dashes don't build

AltStyle によって変換されたページ (->オリジナル) /