Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ReactCommon/Folly to be used in Swift libraries (DEFINES_MODULE) (#31858) #43327

Closed
wants to merge 1 commit into from

Commits on Mar 5, 2024

  1. Allow ReactCommon/Folly to be used in Swift libraries (DEFINES_MODULE) (

    facebook#31858)
    
    Summary:
    <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. -->
    
    ## Summary
    
    Swift Pods require the use of [modular headers](https://blog.cocoapods.org/CocoaPods-1.5.0/) to be statically linked. To interop with Objective-C modules, you need to make the Objective-C module "define a Module", that is modular header export.
    
    This is already the case for a few podspecs so they can be consumed in Swift libraries, but `ReactCommon` and `RCT-Folly` don't do this yet and therefore this breaks in a few libraries of mine, for example see this issue: mrousavy/react-native-vision-camera#195.
    
    If I were to include `ReactCommon` or `RCT-Folly` in my Swift library's podspec, the following error arises:
    
    ```
    [!] The following Swift pods cannot yet be integrated as static libraries:
    
    The Swift pod `VisionCamera` depends upon `RCT-Folly`, which does not define modules.
    To opt into those targets generating module maps (which is necessary to import them from Swift
    when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or
    specify `:modular_headers => true` for particular dependencies.
    ```
    
    So this PR fixes this issue by allowing Swift libraries to consume the `ReactCommon` and `RCT-Folly` podspecs since they now export modular headers.
    
    ## Changelog
    
    <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
    https://github.com/facebook/react-native/wiki/Changelog
    -->
    
    [General] [Fixed] - Expose Modular Headers for `ReactCommon` podspec
    [General] [Fixed] - Expose Modular Headers for `RCT-Folly` podspec
    
    Pull Request resolved: facebook#31858
    
    Test Plan: * Add s.dependency "ReactCommon" or RCT-Folly to a Swift pod and see what happens. (See mrousavy/react-native-vision-camera#273)
    
    Differential Revision: D54539127
    
    Pulled By: cipolleschi
    mrousavy authored and facebook-github-bot committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    1cdaea5 View commit details
    Browse the repository at this point in the history