Baidu App Objective-C/Swift Mixed Programming Practice: Component Module Integration and Binary Publishing
Continuing the Baidu App mixed‑language guide, this article explains how EasyBox‑generated component targets (frameworks and libraries) are organized into modules, configured for Objective‑C/Swift interoperability, unit‑tested, linked across components, and packaged as binaries using module maps, build settings, and lipo merging, while recommending frameworks for smoother distribution.
This article continues from the previous piece on Baidu App's Objective-C/Swift mixed programming impact assessment and implementation steps. It focuses on how Baidu App implements intra-component mixed programming, unit testing, binary publishing, and integration using the EasyBox dependency management tool, as well as inter-component dependency and reference management.
The article first introduces two important concepts: Component Target types and Module organization. EasyBox generates Xcode sub-projects with Targets of types including dynamic_library, static_library, static_framework, and dynamic_framework. Each Target may have companion Targets like bundle, octest_bundle, unit_test_bundle, and ui_test_bundle.
For Module organization, the article explains that a module is a compilation unit or build product that provides a structured alternative encapsulation for a software library. Key concepts include umbrella header (the root header file that publicly exposes all other public headers in a module) and modulemap (which describes the relationship between modules and module headers). The article details module-related build settings including DEFINES_MODULE, MODULEMAP_FILE, HEADER_SEARCH_PATHS, PRODUCT_MODULE_NAME, FRAMEWORK_SEARCH_PATHS, OTHER_CFLAGS, OTHER_LDFLAGS, SWIFT_INCLUDE_PATHS, and OTHER_SWIFT_FLAGS.
For intra-component mixed programming, the article covers two scenarios: Framework and Library. For Framework Targets, no special configuration is needed as long as there's an umbrella header. For Library Targets, module transformation is required, and the article explains how Objective-C references Swift and vice versa.
For inter-component dependencies, the article explains how to configure Build Settings when depending on Framework or Library components, including handling swiftmodule dependencies and compilation order control.
The binary packaging section covers module transformation, compatibility settings using BUILD_LIBRARY_FOR_DISTRIBUTION, Swift Objective-C interface header merging, swiftmodule file merging, binary merging using lipo, and the transitive dependency nature of swiftmodules.
The article concludes with common questions about Swift/Objective-C interoperability, recommendations to use Framework over Library, and notes on Swift binary linking requirements.
Baidu App Technology
Official Baidu App Tech Account
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.