glideapps / glideapps/quicktype

Swift: use file-private JSON helpers for standalone output

Open Beginner friendly
#3,093 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 53m
Merged PRs (30d)
369

Description

## Problem

Swift output generated with `--initializers` contains module-level `newJSONDecoder()` and `newJSONEncoder()` helpers. When multiple schemas are generated separately and added to the same Swift target, each file defines the same functions and compilation fails with `Invalid redeclaration`.

The original fix in #1168 made these helpers `fileprivate`. They were later moved to `JSONSchemaSupport.swift` in commit ff61903b8, where they were changed back to internal visibility so model files could call the shared support file.

## Expected behavior

- Standalone/single-file output: helpers should be `fileprivate`, allowing multiple generated files in one module.
- `--multi-file-output`: helpers in `JSONSchemaSupport.swift` must remain module-visible because model files call them.

## Proposed fix

Emit `fileprivate` when `multiFileOutput` is disabled, and keep the current internal visibility when it is enabled. Add regression coverage for both modes.

Related: #1166, #1168.

Contributor guide

Open the contributing guide

Research direction

Start with the Swift output path that handles the `multiFileOutput` option and the `JSONSchemaSupport.swift` helpers. Compare standalone output with `--multi-file-output`, then add regression coverage for both modes and verify that standalone generated files compile together while multi-file model files still access the helpers.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.