Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefinition of module ReactCommon when upgrading to 0.74 #284

Closed
justbaum30 opened this issue May 7, 2024 · 8 comments
Closed

Redefinition of module ReactCommon when upgrading to 0.74 #284

justbaum30 opened this issue May 7, 2024 · 8 comments

Comments

@justbaum30
Copy link

justbaum30 commented May 7, 2024

Old Version

0.73.8

New Version

0.74.1

Description

After upgrading to 0.74.1, I am no longer able to build the application on iOS. I receive build errors indicating that the ReactCommon module is redefined. Usually it's with React-RuntimeApple but I have also seen it with RCTAppDelegate.

I am able to reproduce by simply adding the same dependencies and Podfile as I have in the reproducer repository.

Steps to reproduce

  1. Install the application with npm install
  2. Install the iOS dependencies with pod install
  3. Try to run the application with npm run start

Affected Platforms

Runtime - iOS, Build - MacOS

Output of npx react-native info

System:
  OS: macOS 14.4
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 49.57 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.19.0
    path: ~/.nvm/versions/node/v18.19.0/bin/node
  Yarn: Not Found
  npm:
    version: 10.2.3
    path: ~/.nvm/versions/node/v18.19.0/bin/npm
  Watchman:
    version: 2023.11.06.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "29"
      - "30"
      - "31"
      - "33"
      - "34"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 34.0.0
      - 35.0.0
    System Images:
      - android-30 | Google APIs Intel x86 Atom
      - android-31 | Google APIs Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
      - android-34 | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11709847
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.6
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.1
    wanted: 0.74.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

/Users/justinbaumgartner/Development/NVA/hhp-mobile/nvaMobileGP/ios/Pods/Headers/Public/ReactCommon/ReactCommon.modulemap:1:8: error: redefinition of module 'ReactCommon'
module ReactCommon {
       ^
/Users/justinbaumgartner/Development/NVA/hhp-mobile/nvaMobileGP/ios/Pods/Headers/Public/ReactCommon/React-RuntimeApple.modulemap:1:8: note: previously defined here
module ReactCommon {
       ^
1 error generated.

....

** BUILD FAILED **


The following build commands failed:
	CompileC /Users/justinbaumgartner/Library/Developer/Xcode/DerivedData/nvaMobileGP-biigwvvmhyomegaepvdbpuhuakly/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTAppDelegate.build/Objects-normal/x86_64/React-RCTAppDelegate-dummy.o /Users/justinbaumgartner/Development/NVA/hhp-mobile/nvaMobileGP/ios/Pods/Target\ Support\ Files/React-RCTAppDelegate/React-RCTAppDelegate-dummy.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-RCTAppDelegate' from project 'Pods')
(1 failure)
]

Reproducer

https://github.com/justbaum30/rn-74-upgrade-reproducer

Screenshots and Videos

Screenshot 2024-05-07 at 4 34 31 PM

@MarceloCajueiro
Copy link

Same thing happening here.

@anuragipankaj
Copy link

same thing with me

@cipolleschi
Copy link
Collaborator

Hi there! Sorry for the long delay, but with the React Conf coming up I hadn't time to look into this.
I'm cloning the reproducer now to see what's going on! Thanks @justbaum30 for providing it!

@cipolleschi
Copy link
Collaborator

Hi There, I had a look at this issue. It looks like you are using Firebase in the app.

When using Firebase, you have to follow the Firebase setup steps.

Once that's done, you'll find another problem in RNCheckNotificationPermission library. This import is broken, there is no rNCheckNotificationPermission file in the library. That line should be replaced by the following.

- #import "rNCheckNotificationPermission-Swift.h"
+ #import "RNCheckNotificationPermission/RNCheckNotificationPermission-Swift.h"

with these two changes, the build will fail because the GOOGLE_APP_ID setting is missing. This should help.

@elgambet
Copy link

elgambet commented Jun 7, 2024

I'm using Crashlytics and experiencing the same issue with Xcode Version 15.4. Initially, I was using version 0.72.5, and iOS builds were successful. However, after upgrading to version 0.74.2, this error began to occur. I tried installing version 0.73.8, and it does work there.

In my project, the pods are being added like this:

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

I tried changing the configuration to:

use_frameworks! :linkage => :static

but this generated other sorts of errors.

I have attempted to clean the build folder and erase the derived data, but these steps did not resolve the issue with version 0.74.2. For now, I will use version 0.73.8 until a fix for this error can be found.

Additionally, I am not using RNFirebase.

Any assistance would be greatly appreciated.

@eunbae0
Copy link

eunbae0 commented Jun 10, 2024

Hi. I fixed this issue through the process of adding and deleting from the code below.

$RNFirebaseAsStaticFramework = false // delete
$RNFirebaseAnalyticsWithoutAdIdSupport = true // delete

use_modular_headers! // delete

target 'YOUR_TARGET' do
  config = use_native_modules!

  use_frameworks! :linkage => :static # add
  $RNFirebaseAsStaticFramework = true # add

  use_react_native!(
    :path => config[:reactNativePath],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
    )
end

Additionally, I use RNFirebase and upgrade react-native version from 0.71.19 to 0.74.1

@sireeshp
Copy link

@eunbae0 can you please paste POD file, AppDelegate.mm, After I added Firebase it's failed tried your above suggestion but still the same issue.

@eunbae0
Copy link

eunbae0 commented Jun 11, 2024

@sireeshp This is my entire Podfile & AppDelegate.mm

require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, min_ios_version_supported
prepare_react_native_project!

target 'YOUR_TARGET' do
  config = use_native_modules!
  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true

  use_react_native!(
    :path => config[:reactNativePath],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
    )
end

post_install do |installer|
  react_native_post_install(
    installer,
    :mac_catalyst_enabled => false,
  )
  installer.pods_project.targets.each do |target|
    if target.name == "React-Core.common-AccessibilityResources"
      target.remove_from_project
    end
    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
    end
  end
end
#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <CodePush/CodePush.h>
#import <Firebase.h>
#import "RNBootSplash.h"
#import "SDImageCodersManager.h"
#import <SDWebImageWebPCoder/SDImageWebPCoder.h>
#import <React/RCTLinkingManager.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"uoslife";
  self.initialProps = @{};

  [FIRApp configure];

  bool didFinish = [super application:application didFinishLaunchingWithOptions:launchOptions];

  [SDImageCodersManager.sharedManager addCoder:SDImageWebPCoder.sharedCoder];

  return didFinish;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
  return [self bundleURL];
}
 
- (NSURL *)bundleURL
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [CodePush bundleURL];
#endif
}

- (void)customizeRootView:(RCTRootView *)rootView {
  [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView]; // ⬅️ initialize the splash screen
}

- (BOOL)concurrentRootEnabled
{
  return true;
}

- (BOOL)application:(UIApplication *)application
   openURL:(NSURL *)url
   options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [RCTLinkingManager application:application openURL:url options:options];
}

@end

I hope this will help you. And react-native-upgrade-helper might help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done / Picked
Development

No branches or pull requests

7 participants