Swift: use file-private JSON helpers for standalone output
Author: foobraCreated Jul 31, 2026Updated Jul 31, 2026
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 inJSONSchemaSupport.swiftmust 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.
Source: glideapps/quicktype