Skip to content

pod install fails on 0.81 "Some components or modules are declared in more than one libraries" #2816

@Roshan-24

Description

@Roshan-24

Environment

react-native -v:

zsh: command not found: react-native

(package.json has react-native@0.81.5)

npm ls react-native-macos:

Rnm81@0.0.1 /Users/roshanbx/Projects/POC/Rnm81
└── react-native-macos@0.81.0

node -v: `v20.20.0`
npm -v: `10.8.2`
yarn --version: Not installed
xcodebuild -version: 

Xcode 26.0.1
Build version 17A400

Steps to reproduce the bug

  1. Run npx @react-native-community/cli init ProjectName --version 0.81
  2. Run npx react-native-macos-init
  3. cd macos && bundle install && bundle exec pod install

Expected Behavior

pod install should succeed

Actual Behavior

Command errors out with the following log

Found 1 module for target `Rnm81-macOS`
link_native_modules! {:ios_packages=>[{:configurations=>[], :name=>"react-native-safe-area-context", :root=>"/Users/roshanbx/Projects/POC/Rnm81/node_modules/react-native-safe-area-context", :path=>"../node_modules/react-native-safe-area-context", :podspec_path=>"/Users/roshanbx/Projects/POC/Rnm81/node_modules/react-native-safe-area-context/react-native-safe-area-context.podspec", :script_phases=>[]}], :ios_project_root_path=>"/Users/roshanbx/Projects/POC/Rnm81/ios", :react_native_path=>"../node_modules/react-native"}
Auto-linking React Native module for target `Rnm81-macOS`: react-native-safe-area-context
get_default_flags is deprecated. Please remove the keys from the `use_react_native!` function
if you are using the default already and pass the value you need in case you don't want the default
Framework build type is static library
[ReactNativeDependencies] Setting up ReactNativeDependencies...
[ReactNativeDependencies] Building from source: true
[ReactNativeDependencies] Source: 
[ReactNativeCore] Setting up ReactNativeCore...
[ReactNativeCore] Building from source: true
[ReactNativeCore] Source: 
Configuring the target with the New Architecture

[!] Invalid `Podfile` file: [!] /Users/roshanbx/.local/share/mise/installs/node/20.20.0/bin/node macos/../node_modules/react-native-macos/scripts/generate-codegen-artifacts.js -p /Users/roshanbx/Projects/POC/Rnm81/macos/.. -o /Users/roshanbx/Projects/POC/Rnm81/macos -t ios

[Codegen] Analyzing /Users/roshanbx/Projects/POC/Rnm81/package.json
[Codegen] Could not find generated autolinking output at: /Users/roshanbx/Projects/POC/Rnm81/macos/build/generated/autolinking/autolinking.json
[Codegen] Searching for codegen-enabled libraries in the app.
[Codegen] The "codegenConfig" field is not defined in package.json. Assuming there is nothing to generate at the app level.
[Codegen] Could not find generated autolinking output at: /Users/roshanbx/Projects/POC/Rnm81/macos/build/generated/autolinking/autolinking.json
[Codegen] Searching for codegen-enabled libraries in the project dependencies.
[Codegen] Found react-native
[Codegen] CodegenConfig Deprecated Setup for react-native.
    The configuration file still contains the codegen in the libraries array.
    If possible, replace it with a single object.
  
[Codegen] BEFORE:
    {
      // ...
      "codegenConfig": {
        "libraries": [
          {
            "name": "libName1",
            "type": "all|components|modules",
            "jsSrcsRoot": "libName1/js"
          },
          {
            "name": "libName2",
            "type": "all|components|modules",
            "jsSrcsRoot": "libName2/src"
          }
        ]
      }
    }

    AFTER:
    {
      "codegenConfig": {
        "name": "libraries",
        "type": "all",
        "jsSrcsRoot": "."
      }
    }
  
[Codegen] Found react-native-macos
[Codegen] Found react-native-safe-area-context
[Codegen] Searching for codegen-enabled libraries in react-native.config.js
[Codegen] Processing FBReactNativeSpec
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Processing FBReactNativeSpec
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Processing safeareacontext
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Supported Apple platforms: ios, macos, tvos, visionos for safeareacontext
[Codegen] [Codegen - FBReactNativeSpec] Skipping iOS code generation for FBReactNativeSpec as it has been generated already.
[Codegen] [Codegen - FBReactNativeSpec] Skipping iOS code generation for FBReactNativeSpec as it has been generated already.
[Codegen] Generating Native Code for safeareacontext - ios
[Codegen] Generated artifacts: /Users/roshanbx/Projects/POC/Rnm81/macos/build/generated/ios
[Codegen] Generating RCTThirdPartyComponentsProvider.h
[Codegen] Generated artifact: /Users/roshanbx/Projects/POC/Rnm81/macos/build/generated/ios/RCTThirdPartyComponentsProvider.h
[Codegen] Generating RCTThirdPartyComponentsProvider.mm
[Codegen] Generated artifact: /Users/roshanbx/Projects/POC/Rnm81/macos/build/generated/ios/RCTThirdPartyComponentsProvider.mm
[Codegen] Generating RCTModulesProvider.h
[Codegen] Generated artifact: /Users/roshanbx/Projects/POC/Rnm81/macos/build/generated/ios/RCTModuleProviders.h
[Codegen] Generating RCTModuleProviders.mm
[Codegen] Generated artifact: /Users/roshanbx/Projects/POC/Rnm81/macos/build/generated/ios/RCTModuleProviders.mm
[Codegen] Error: Some components or modules are declared in more than one libraries: 
  Module { "AccessibilityManager" } => Libraries{ react-native, react-native-macos }

  Module { "Appearance" } => Libraries{ react-native, react-native-macos }

  Module { "AppState" } => Libraries{ react-native, react-native-macos }

  Module { "DeviceInfo" } => Libraries{ react-native, react-native-macos }

  Module { "PlatformConstants" } => Libraries{ react-native, react-native-macos }

  Module { "StatusBarManager" } => Libraries{ react-native, react-native-macos }

[Codegen] Done.
.

 #  from /Users/roshanbx/Projects/POC/Rnm81/macos/Podfile:18
 #  -------------------------------------------
 #  
 >    use_react_native!(
 #      :path => '../node_modules/react-native-macos',
 #  -------------------------------------------

Reproducible Demo

Additional context

This is probably because of the new config structure for codegenConfig in package.json - https://github.com/microsoft/react-native-macos/blob/main/packages/react-native/package.json#L200C3-L231C4

If i change the structure back to how it was in previous versions in both react-native's package.json and react-native-macos's package.json, it works as normal

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions