Repository: react-native
Issue: Codegen not respecting ignored linked dependencies in react-native.config.js 
Labels: Resolution: PR Submitted,Type: New Architecture

### Description

When a third party react-native dependency exists in an app's package.json but has been disabled from auto-linking in the `react-native.config.js` file, react-native-codegen still generates native Objective-C code for the unlinked dependency, leading to build failures.



### Steps to reproduce

Create a new RN project and add a third party library that contains native code (e.g. `react-native-screens`)

```
npx @react-native-community/cli@latest init VerifyCodegen --skip-install --version 0.76.1
cd VerifyCodegen
yarn install
yarn add react-native-screens
```

Create a `react-native.config.js` file and disable `react-native-screens` from auto-linking on iOS...

```
module.exports = {
  dependencies: {
    'react-native-screens': {
      platforms: {
        ios: null,
        android: null,
      },
    },
  },
};
```

Run pod install and try and build/run the iOS app

```
npx pod-install
yarn ios
```

Build will fail because the generated `RCTThirdPartyFabricComponentsProvider` files reference things that are linked in the project (e.g. `_RNSScreenCls`).

### React Native Version

0.76.1

### Affected Platforms

Runtime - iOS

### Areas

Codegen

### Output of `npx react-native info`

```text
info Fetching system and libraries information...
System:
  OS: macOS 14.6.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 190.97 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.0
    path: ~/.nvm/versions/node/v18.18.0/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v18.15.0/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.0/bin/npm
  Watchman:
    version: 2024.04.01.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/brent.kelly/.rvm/gems/ruby-2.7.5/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 2.7.5
    path: /Users/brent.kelly/.rvm/rubies/ruby-2.7.5/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: 15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
```
```


### Stacktrace or Logs

```text
Undefined symbols for architecture arm64:
  "_RNSFullWindowOverlayCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSModalScreenCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSScreenCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSScreenContainerCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSScreenContentWrapperCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSScreenFooterCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSScreenNavigationContainerCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSScreenStackCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSScreenStackHeaderConfigCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSScreenStackHeaderSubviewCls", referenced from:
      _RCTThirdPartyFabricComponentsProvider in libReact-RCTFabric.a[41](RCTThirdPartyFabricComponentsProvider.o)
  "_RNSSearchBarCls", 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)
```

### Reproducer

https://github.com/mrbrentkelly/rn-codegen-linking-bug

### Screenshots and Videos

_No response_