zoontek / react-native-localize

🌍 A toolbox for your React Native app localization
MIT License
2.26k stars 210 forks source link

Redefinition of NativeRNLocalizeSpecJSI #238

Closed alexanderoskin closed 9 months ago

alexanderoskin commented 9 months ago

Bug summary

Related to https://github.com/zoontek/react-native-localize/issues/229

Redefinition of 'NativeRNLocalizeSpecJSI' during iOS build when new arch enabled. Redefinition comes from this lines https://github.com/zoontek/react-native-localize/blob/36b74d3bade1e7be8f7be134c2eb8816d75953fc/ios/RNLocalize.mm#L3C1-L5C7

Previous definition is in the react-native-codegen generated file.

/**
 * 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 codegen project: GenerateModuleObjCpp
 *
 * We create an umbrella header (and corresponding implementation) here since
 * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
 * must have a single output. More files => more genrule()s => slower builds.
 */

#ifndef __cplusplus
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
#endif
#import <Foundation/Foundation.h>
#import <RCTRequired/RCTRequired.h>
#import <RCTTypeSafety/RCTConvertHelpers.h>
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTCxxConvert.h>
#import <React/RCTManagedPointer.h>
#import <ReactCommon/RCTTurboModule.h>
#import <optional>
#import <vector>

@protocol NativeRNLocalizeSpec <RCTBridgeModule, RCTTurboModule>

- (NSString *)getCalendar;
- (NSString *)getCountry;
- (NSArray<NSString *> *)getCurrencies;
- (NSArray<NSDictionary *> *)getLocales;
- (NSDictionary *)getNumberFormatSettings;
- (NSString *)getTemperatureUnit;
- (NSString *)getTimeZone;
- (NSNumber *)uses24HourClock;
- (NSNumber *)usesMetricSystem;
- (NSNumber * _Nullable)usesAutoDateAndTime;
- (NSNumber * _Nullable)usesAutoTimeZone;

@end
namespace facebook {
  namespace react {
    /**
     * ObjC++ class for module 'NativeRNLocalize'
     */
    class JSI_EXPORT NativeRNLocalizeSpecJSI : public ObjCTurboModule {
    public:
      NativeRNLocalizeSpecJSI(const ObjCTurboModule::InitParams &params);
    };
  } // namespace react
} // namespace facebook

This line class JSI_EXPORT NativeRNLocalizeSpecJSI : public ObjCTurboModule

Library version

3.0.3

Environment info

System:
  OS: macOS 14.1.1
  CPU: (8) arm64 Apple M1
  Memory: 98.17 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.7.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.1.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2023.09.18.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/alexander/.rvm/gems/ruby-2.7.6/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.20.1
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/alexander/.rvm/rubies/ruby-2.7.6/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.7
    wanted: ^0.72.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: true

Steps to reproduce

  1. Install this library
  2. Enable new arch
  3. Build iOS

Reproducible sample code

-
zoontek commented 9 months ago

@alexanderoskin It does not result in an error on my side (I can compile the app without any error), but as it's already imported in the header file, it can be removed. Fixed in 3.0.4.