bazelbuild / bazelbuild/rules_apple
Add ability to concatenate Swift source files produced with apple_core_data_model
- Dominant language
- Starlark
- Stars
- 593
- Forks
- 334
- Avg merge
- 16h 48m
- Merged PRs (30d)
- 9
Description
Today, `apple_core_data_model` produces a directory as its output file rather than individual Swift file outputs. This is because, under the hood, this rule invokes `xcrun momc --action generate`, which produces multiple Swift files from a single input file, and there's no way to know during the analysis phase what Swift files will be created.
Using a directory as an output rather than individual Swift files is problematic. For example, `swift_library` [does not support using a directory](https://github.com/bazelbuild/rules_swift/issues/969) in its `srcs` without a hacky workaround.
I'd like to propose a fix for this specific issue where, instead of only producing a directory of source files, `apple_core_data_model` provides an optional attribute `merge_outputs = True`. When set, the rule merges all Swift output files into a single Swift source file. This file can be known statically during analysis and can be included in the `srcs` list of a `swift_library` without the need for a hacky workaround.
Contributor guide
Research direction
Start with the apple_core_data_model rule and its xcrun momc --action generate invocation, then review how swift_library consumes srcs. Trace how the rule declares its directory output and determine where an optional merge_outputs attribute would fit. Done means the rule can expose one statically named merged Swift source file while preserving the existing directory output behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100