Skip to content

New architecture compiling error #6

@christofferj95

Description

@christofferj95

I'm running into issues with the new architecture using react native version 0.76.6 on iOS.

› Compiling @luckypear/react-native-thumbhash Pods/react-native-thumbhash » ThumbhashModule.mm

❌  (node_modules/@luckypear/react-native-thumbhash/ios/ThumbhashModule.mm:16:17)

  14 | 
  15 | #ifdef RCT_NEW_ARCH_ENABLED
> 16 | using namespace facebook::react;
     |                 ^ use of undeclared identifier 'facebook'
  17 | 
  18 | @interface ThumbhashModule () <NativeThumbhashModuleSpec>
  19 | @end


❌  (node_modules/@luckypear/react-native-thumbhash/ios/ThumbhashModule.mm:18:32)

  16 | using namespace facebook::react;
  17 | 
> 18 | @interface ThumbhashModule () <NativeThumbhashModuleSpec>
     |                                ^ cannot find protocol declaration for 'NativeThumbhashModuleSpec'
  19 | @end
  20 | #endif
  21 | 


❌  (node_modules/@luckypear/react-native-thumbhash/ios/ThumbhashModule.mm:54:4)

  52 | // Don't compile this code when we build for the old architecture.
  53 | #ifdef RCT_NEW_ARCH_ENABLED
> 54 | - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
     |    ^ expected a type
  55 |     (const facebook::react::ObjCTurboModule::InitParams &)params
  56 | {
  57 |     return std::make_shared<facebook::react::NativeTestSpecJSI>(params);


❌  (node_modules/@luckypear/react-native-thumbhash/ios/ThumbhashModule.mm:55:12)

  53 | #ifdef RCT_NEW_ARCH_ENABLED
  54 | - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
> 55 |     (const facebook::react::ObjCTurboModule::InitParams &)params
     |            ^ use of undeclared identifier 'facebook'
  56 | {
  57 |     return std::make_shared<facebook::react::NativeTestSpecJSI>(params);
  58 | }


❌  (node_modules/@luckypear/react-native-thumbhash/ios/ThumbhashModule.mm:57:17)

  55 |     (const facebook::react::ObjCTurboModule::InitParams &)params
  56 | {
> 57 |     return std::make_shared<facebook::react::NativeTestSpecJSI>(params);
     |                 ^ no template named 'make_shared' in namespace 'std'; did you mean 'make_signed'?
  58 | }
  59 | #endif
  60 | 


❌  (node_modules/@luckypear/react-native-thumbhash/ios/ThumbhashModule.mm:57:29)

  55 |     (const facebook::react::ObjCTurboModule::InitParams &)params
  56 | {
> 57 |     return std::make_shared<facebook::react::NativeTestSpecJSI>(params);
     |                             ^ use of undeclared identifier 'facebook'
  58 | }
  59 | #endif
  60 | 

Solution for now is using the old architecture.

//
//  ThumbhashModule.m
//  react-native-thumbhash
//
//  Created by 윤종배 on 7/23/24.
//
#import "ThumbhashModule.h"

#if __has_include("react_native_thumbhash/react_native_thumbhash-Swift.h")
#import "react_native_thumbhash/react_native_thumbhash-Swift.h"
#else
#import "react_native_thumbhash-Swift.h"
#endif

// Comment out problematic new architecture code
// #ifdef RCT_NEW_ARCH_ENABLED
// #import <React/RCTFabricComponentsPlugins.h>
// #import <React-Codegen/NativeThumbhashModuleSpec.h>
// using namespace facebook::react;

// @interface ThumbhashModule () <NativeThumbhashModuleSpec>
// @end
// #endif

@interface ThumbhashModule ()

@property (nonatomic, strong) ThumbhashModuleImpl *impl;

@end

@implementation ThumbhashModule 
RCT_EXPORT_MODULE()

@synthesize moduleRegistry = _moduleRegistry;

RCT_EXPORT_METHOD(encode
                  : (NSString *)imageUri
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject
                  )
{
    [self.impl encode:imageUri
                              resolver:resolve
                              rejecter:reject];
}

- (ThumbhashModuleImpl *)impl
{
  if (!_impl) {
    _impl = [[ThumbhashModuleImpl alloc] initWithModuleRegistry:_moduleRegistry];
  }
  return _impl;
}

// Comment out problematic new architecture code
// #ifdef RCT_NEW_ARCH_ENABLED
// - (std::shared_ptr<TurboModule>)getTurboModule:
//     (const ObjCTurboModule::InitParams &)params
// {
//     return std::make_shared<NativeThumbhashModuleSpecJSI>(params);
// }
// #endif

@end

Might look into this myself in a month or so, how would you prefer that external people contribute to the project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions