Why
Xcode is the official method for making apps for iOS, tvOS, and watchOS. You can use RE2 in an Xcode project in two ways. The first one doesn't change the current CMakeLists.txt file, but the user needs to do the following: (1) Make multiple libre2.a files, each for a different OS-arch combination, like libre2-ios-arm64, libre2-ios-simulator-arm64, libre2-ios-simulator-x86 64, libre2-tvos-arm64, and libre2-watchos-arm64. (2) Drag and drop all of these libre2-os-arch.a files into the Xcode project, and then set the project targets to the appropriate library. (3) Drag-and-drop the RE2 header files into the Xcode project and set the include path. Because of how complicated (3) was, Apple came up with the idea of Framework, which is a directory called a bundle that contains the header files and a certain version of libre2.a. My Pull Request makes it possible for these kinds of frameworks to be built for Apple platforms. It also lets us run a command called "xcodebuild -create-framework" after the process is done to combine all of these frameworks that depend on the platform into a higher-level bundle called "re2.xcframework." So Xcode users just drag and drop a single bundle into the project. This takes care of the difficulties in (1) and (2).
Conditional
This makes sense. CMake To get it, I think we can add a RE2_BUILD_FRAMEWORK option to my prototype Pull Request. CMake doesn't have a flag for "add_library" like BUILD_SHARED LIBS that lets you build frameworks. This is because the framework and shared/static libraries are not on the same logical layer. If BUILD SHARED LIBS is set, a framework does have a shared library. It has a static library if it is not set. However, we can condition the call to set_target_properties by using RE2_BUILD_FRAMEWORK AND APPLE.
Expose header files
Framework and XCFramework are used to release header files and libraries at the same time. "add library" needs to know which header files to add to the framework. But if you can split RE2 header files into a public group and an internal group, and make sure that public header files don't include internal ones, we can definitely avoid including all of them.