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

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

Open
cipolleschi opened this issue Nov 3, 2023 · 0 comments
Labels
bug Something isn't working Needs: Triage 🔍

Comments

@cipolleschi
Copy link

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 @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!

@cipolleschi cipolleschi added the bug Something isn't working label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Needs: Triage 🔍
Projects
None yet
Development

No branches or pull requests

1 participant