Skip to content

React-Native-MacOS does not support use_frameworks!, :linkage => :dynamic  #1969

Closed

Description

Environment

react-native -v: 0.73
npm ls react-native-macos: 1000.0.0
node -v: v18.14
npm -v: 8.12.1
yarn --version: 1.22.19
xcodebuild -version:
Xcode 15.1
Build version 15C5028h

Steps to reproduce the bug

I was helping out Shawn Dempsey (@shwanton) in supporting use_frameworks! in react-native-macos.

I managed to have them working with :linkage => :static and the Old Architecture in this PR.

I then started looking into :linkage => :dynamic in the Old Architecture and I hit a wall. MacOS has some circular dependencies that needs to be fixed as dynamic frameworks need to be able to build in isolation and circular dependencies prevent that, unfortunately.

The two dependencies I found are:
First

  • RCTView depends on RCTText becauese of this
  • RCTText depends on React-Core because of this
  • React-Core owns RCTView, thus, the circular dependency

Second

  • RCTTouchHandler depends on RCTText because of this
  • RCTText depends on React-Core because of this
  • React-Core owns RCTView, thus, the circular dependency.

There are various way that we can use to break those:

  • we can create a couple of protocols in React-Core, make the RCTText classes conform to them and use them to decide what to do.
  • if the RCTText classes exposes some specific selector that are custom to them, we can use that instead of the class name
  • if the RCTText classes has some values we can leverage at runtime to make the decision, we can use them.

Expected Behavior

Being able to build with use_frameworks!, :linkage => :dynamic

Actual Behavior

Fails to build
Screenshot 2023-11-03 at 16 10 34

Reproducible Demo

  1. git clone https://github.com/microsoft/react-native-macos
  2. cd react-native-macos
  3. yarn
  4. cd packages/rn-tester
  5. bundle install
  6. NO_FLIPPER=1 USE_FRAMEWORKS=dynamic bundle exec pod install
  7. open RNTestProject.xcworkspace
  8. Select the RNTester-MacOS target
  9. cmd + B

Additional context

On mobile, use_frameworks! is a requirement for Firebase, for example. Perhaps Firebase is not compatible with MacOS?
Or aren't there libraries which requires that to be turned on?

Enabling and supporting Swift, requires a folder structure which is exactly the one enforced by frameworks (Clang modules) so it make sense to make sure we support it.

Dynamic frameworks will also catch those circular dependencies automatically!

Activity

  1. maksimlya commented on Jun 4, 2024

    @maksimlya

    Hi, I just got this issue as well. I need this to be able to use CocoaAsyncSocket library. Any workaround/solution?

  2. Saadnajmi commented on Jun 4, 2024

    @Saadnajmi
    Collaborator

    No workaround / solution at the moment. For my own knowledge, what kind of issue do you run into when you try to use something like CocoaAsyncSocket without frameworks?

  3. maksimlya commented on Jun 4, 2024

    @maksimlya

    https://github.com/robbiehanson/CocoaAsyncSocket

    According to their instructions, if I want to run it from swift I need to add the framework:

    use_frameworks! # Add this if you are targeting iOS 8+ or using Swift
    pod 'CocoaAsyncSocket'  
    

    Without adding the framework, Swift simply cannot find the lib.

    But it's ok, since I just downloaded the source code and linked it manually to the project. TCP works fine, thx for the help.

  4. hryhoriiK97 commented on Jun 25, 2026

    @hryhoriiK97

    Hey Saad Najmi (@Saadnajmi), I ran into this issue while working on react-native-enriched-markdown. We need use_frameworks! to integrate an SPM dependency (RaTeX for LaTeX math rendering) via CocoaPods' spm_dependency.

    As described in this issue, :linkage => :dynamic fails due to circular deps between React-Core and React-RCTText.

    I also tried :linkage => :static but that breaks too — React-Fabric fails to build with 'react/renderer/components/view/KeyEvent.h' file not found. The problem is that the view subspec includes headers from both platform/cxx/ and platform/macos/, and with use_frameworks! the compiler picks up the wrong (cxx) version instead of the macOS one.

    Is there any plan to fix use_frameworks! support for macOS? We're on react-native-macos 0.81.4.

  5. Saadnajmi commented on Jun 25, 2026

    @Saadnajmi
    Collaborator

    Gregory Moskaliuk (@hryhoriiK97) Prior to your comment, I had no plans to fix this as apart from firebase I hadn't seen much usage of dynamic linkning apart from firebase. Now that I see it blocks SPM deps, I will take another look. Unsure it'll land with our next release (0.83), but maybe right after and I'll backport? Thank you for bringing to my attention!

  6. Saadnajmi commented on Jul 10, 2026

    @Saadnajmi
    Collaborator

    Hello Gregory Moskaliuk (@hryhoriiK97) I have the changes to support dynamic frameworks here #2943
    They are quite big, and I wanted to double check if they were still necessaryy for enriched markdown so I decide how / when to land them?

  7. hryhoriiK97 commented on Jul 10, 2026

    @hryhoriiK97

    Hi Saad Najmi (@Saadnajmi), yes, this is a big blocker for us right now. We disabled LaTeX support for macOS in 0.7.0, so if you can push this, we'd appreciate it so much 🙌

  8. added a commit that references this issue on Jul 13, 2026
    0527520
  9. Saadnajmi commented on Oct 12, 2026

    @Saadnajmi
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions