microsoft / react-native-macos

A framework for building native macOS apps with React.
https://microsoft.github.io/react-native-windows/
MIT License
3.35k stars 128 forks source link

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

Open cipolleschi opened 8 months ago

cipolleschi commented 8 months ago

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

Second

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

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!

maksimlya commented 1 month ago

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

Saadnajmi commented 1 month ago

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?

maksimlya commented 1 month ago

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.