bazelbuild / bazelbuild/rules_apple
`objc_library` cannot use `@import` syntax for dependencies due to lack of automatic module map propagation
- Dominant language
- Starlark
- Stars
- 593
- Forks
- 334
- Avg merge
- 16h 48m
- Merged PRs (30d)
- 9
Description
**Problem Description:**
When building pure Objective-C code using Bazel's `objc_library` rule, it is currently difficult or impossible to reliably use the modern `@import` module syntax for dependencies. While Objective-C supports both the traditional `#import`/`#include` and the `@import` syntax, the latter requires a module map file (`module.modulemap`) for the dependency to be generated and correctly passed to the compiler.
**Details:**
1. The `@import` syntax depends on the compiler having access to a module map for the imported library. This mechanism is fundamental to how modules work in Clang and is used for both Objective-C and Swift.
2. Rules within `bazelbuild/rules_swift`, such as `swift_library` and `mixed_language_library`, have established mechanisms for generating and propagating module maps of their dependencies. This is crucial for enabling interoperability between Swift and Objective-C code within modules.
3. However, the standard `objc_library` rule does not appear to automatically generate or propagate module maps for its *pure Objective-C* dependencies in a way that consistently enables the use of `@import` syntax from within dependent `objc_library` targets. While there is an `enable_modules` attribute on `objc_library`, it seems insufficient on its own to handle the full dependency graph correctly for `@import` between `objc_library` targets.
4. In contrast, other build systems (like Swift Package Manager) handle the generation and use of module maps for Objective-C dependencies more automatically, allowing for smoother adoption of the `@import` syntax.
**Desired Enhancement:**
It would be beneficial if `objc_library` could automatically generate and manage module maps for their dependencies. This automatic propagation of module information should enable reliable use of the `@import` syntax throughout a pure Objective-C dependency graph defined by `objc_library` rules, similar to how it functions for mixed-language targets or in other build environments.
antly.
Contributor guide
Research direction
Start by examining the objc_library rule and its enable_modules attribute, then compare its module-map handling with the mechanisms described for swift_library and mixed_language_library. The work is done when pure Objective-C dependency graphs reliably propagate module maps and allow dependent targets to use @import syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100