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:
- 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.
- 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.
- 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.
- 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.
Problem Description:
When building pure Objective-C code using Bazel's
objc_libraryrule, it is currently difficult or impossible to reliably use the modern@importmodule syntax for dependencies. While Objective-C supports both the traditional#import/#includeand the@importsyntax, the latter requires a module map file (module.modulemap) for the dependency to be generated and correctly passed to the compiler.Details:
@importsyntax 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.bazelbuild/rules_swift, such asswift_libraryandmixed_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.objc_libraryrule 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@importsyntax from within dependentobjc_librarytargets. While there is anenable_modulesattribute onobjc_library, it seems insufficient on its own to handle the full dependency graph correctly for@importbetweenobjc_librarytargets.@importsyntax.Desired Enhancement:
It would be beneficial if
objc_librarycould automatically generate and manage module maps for their dependencies. This automatic propagation of module information should enable reliable use of the@importsyntax throughout a pure Objective-C dependency graph defined byobjc_libraryrules, similar to how it functions for mixed-language targets or in other build environments.antly.