facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.82k stars 24.29k forks source link

[0.76][iOS][Codegen] Fabric Native Component from website has a bug #47175

Open blakef opened 3 hours ago

blakef commented 3 hours ago

Description

Currently codegen generates RCTThirdPartyFabricComponents wrappers with references to the Fabric Components. If these components are inlined in your application, they fail to build (as the they're linked in the Pods and not the App, so can't find the symbols). You'll see an error similar to this (except your component class will be missing):

Undefined symbols for architecture arm64:
  "_CustomWebViewCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

We're expecting a fix to ship in 0.76.1 (#47176), but leaving this issue here as a placeholder until that's the case.

Appendix:

See commented out lines, which you'll have to do until the fix ships.


/*
 * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
 *
 * Do not edit this file as changes may cause incorrect behavior and will be lost
 * once the code is regenerated.
 *
 * @generated by GenerateRCTThirdPartyFabricComponentsProviderH
 */

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"

#import <React/RCTComponentViewProtocol.h>

#ifdef __cplusplus
extern "C" {
#endif

Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name);
#if RCT_NEW_ARCH_ENABLED
#ifndef RCT_DYNAMIC_FRAMEWORKS

//Class<RCTComponentViewProtocol> CustomWebViewCls(void) __attribute__((used)); // 0

#endif
#endif

#ifdef __cplusplus
}
#endif

#pragma GCC diagnostic pop

and


/**
 * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
 *
 * Do not edit this file as changes may cause incorrect behavior and will be lost
 * once the code is regenerated.
 *
 * @generated by GenerateRCTThirdPartyFabricComponentsProviderCpp
 */

// OSS-compatibility layer

#import "RCTThirdPartyFabricComponentsProvider.h"

#import <string>
#import <unordered_map>

Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) {
  static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
    #if RCT_NEW_ARCH_ENABLED
    #ifndef RCT_DYNAMIC_FRAMEWORKS

//    {"CustomWebView", CustomWebViewCls}, // 0
    #endif
    #endif
  };

  auto p = sFabricComponentsClassMap.find(name);
  if (p != sFabricComponentsClassMap.end()) {
    auto classFunc = p->second;
    return classFunc();
  }
  return nil;
}

Steps to reproduce

N/A

React Native Version

0.76.0

Affected Platforms

Runtime - iOS, Build - MacOS

Output of npx react-native info

N/A

Stacktrace or Logs

N/A

Reproducer

https://github.com/cipolleschi/InAppComponent

Screenshots and Videos

CleanShot 2024-10-23 at 08 59 15@2x

react-native-bot commented 3 hours ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
react-native-bot commented 3 hours ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
shubhamguptadream11 commented 2 hours ago

@blakef Is this already picked by someone and is being tracked in some PR?

blakef commented 2 hours ago

Updated to reference the PR: #47176