-
Notifications
You must be signed in to change notification settings - Fork 306
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:
- The
@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. - Rules within
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. - However, the standard
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. - 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
@importsyntax.
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.