react-native-community / RNNewArchitectureApp

A collection of sample React Native Apps that will show you how to use the New Architecture (Fabric & TurboModules) step-by-step.
MIT License
201 stars 28 forks source link

How to do codegen for iOS if we have both TurboModules and Fabric in our project? #19

Closed BraveEvidence closed 2 years ago

BraveEvidence commented 2 years ago

I have a specification for Fabric and TurboModule in my project. It works for separate project. If I try to write both of them in the same project , it generates a bunch of undefined symbols. I think the issue is in package.json file where we write the codegen code

"codegenConfig": {
    "libraries": [
      {
        "name": "CustomLib",
        "type": "modules",
        "jsSrcsDir": "./js"
      },
      {
        "name": "CustomUILib",
        "type": "components",
        "jsSrcsDir": "./js"
      }
    ]
  }

I tried this but it doesn't seem to work and throws a bunch of undefined symbols error

chakrihacker commented 2 years ago

Can you share a repo to take a look at??

BraveEvidence commented 2 years ago

@chakrihacker Check this https://github.com/PritishSawant/ReactNativeMultipleTurboModulesAndFabricExample

The issue happens for iOS codegen. I have multiple Fabric and TurboModules Spec in js folder and codegen is not able to recognise which one is Fabric and which one is TurboModule so I think the issue happens.

BraveEvidence commented 2 years ago

Looks like on further debugging, the issue is on codgen side for Fabric. Even individual fabric component with no TurboModule in a separate project is not working

Screenshot 2022-07-10 at 10 02 09 AM Screenshot 2022-07-10 at 10 02 25 AM Screenshot 2022-07-10 at 10 03 01 AM

The error logs are for separate project with only fabric module.

cipolleschi commented 2 years ago

Hi @PritishSawant, thanks for your questions. I think you are hitting two different problems, here.

  1. If you want to create a library which has both a TM and a FC, you have to work with it in the same way android does: you have to create a single library that contains both and use the type all. The configuration will look something like this:
    "codegenConfig": {
    "libraries": [
      {
        "name": "CustomLib",
        "type": "all",
        "jsSrcsDir": "./js"
      }
    ]
    }
  2. The error Undefined Symbols for architecture x86_64, _ColoredViewCls means that iOS is not finding the symbol for the ColoredViewCls method. If you look here, you'll see that, at the end of the last iOS file, there is the required method: That is something you have to write, the Codegen can't create that for you because the Codegen does not know the name of the class that actually represents the View in the native world.
BraveEvidence commented 2 years ago

@cipolleschi Thanks closing this